Xtra-Computing / thundersvm

ThunderSVM: A Fast SVM Library on GPUs and CPUs
Apache License 2.0
1.55k stars 215 forks source link

max_iter parameter does not seem to work for SVR #240

Open volpepe opened 3 years ago

volpepe commented 3 years ago

Hi,

For the past days I've been trying to use this library together with sklearn's GridSearchCV in order to find the best parameters for an SVR regressor over some data I collected from a depth camera.

The setup for my experiment is the following:

regr = GridSearchCV(Pipeline(
        steps=[('scaler', StandardScaler()),
                ('svr', SVR(
                    n_jobs=-1,
                    max_iter=100000,
                )
            )
        ]),
        param_grid=SVR_params, 
        cv=3,
        n_jobs=-1)

where SVR_params is the following:

[
    {
        "svr__kernel":   ["polynomial"],
        "svr__degree":   [5, 10, 25, 50, 75, 100, 120, 150],
        "svr__C":        [0.5, 1, 20, 50, 100, 500, 1000],
        "svr__gamma":    [1e-5, 1e-4, 0.001, 0.005, 0.01, 0.05, 0.1, 0.15, 0.2],
        "svr__coef0":    [0, 0.5, 1],
    }
]

I noticed that for most parameter configurations, the library works great, maybe 8/16x than sklearn's implementation using the GPU.

The problem is that there are some parameter configurations that don't allow the algorithm to reach convergence, thus leading to extremely long running times for a single search step (up to 11 hours in my case, while most good configurations are resolved in a matter of seconds).

My solution to this problem was simply adding the max_iter parameter to the SVR as shown in the above code: I know it's not the best solution and setting a higher tolerance would be better, but I think that for the kind of data I'm dealing with, 100000 iterations are more than enough to reach convergence.

However, Thundersvm's SVR seems to ignore this parameter. I tried this in several systems: my work PC, my company server and even some Colab environments. In all cases this library was installed succesfully but the execution would halt for literal hours on the parameter configurations that cause bad convergence, even with the max_iter parameter set to any number different from -1.

On the other hand, I went back to sklearn's implementation of SVR and, even though extremely slower on single iterations, the execution was overall faster and terminated in a reasonable amount of time since the max_iter parameter was correctly preventing bad sets of parameters to make the algorithm run endlessly.

Any help with this problem is well appreciated.

QinbinLi commented 3 years ago

Hi @volpepe ,

Can you provide a simple example to reproduce the bug? Thanks!