According to the documentation, using the parameter n_jobs on a SVR is not supported.
On the other hand, and again from the docs, that parameter is supported at other types of regressor.
- Why is this?
- What is the best method to speed up a regressor in that case?
This is the error traceback I'm getting:
regressor = SVR(kernel='rbf', C=1, n_jobs=-1)
TypeError: __init__() got an unexpected keyword argument 'n_jobs'
I've got some suggestions in relation to your second question.
SVRis slow for lots of samples (tens of thousands), so one option is to resample your data down to a smaller representative sample using stratified sampling.Look into
scikit-learn-intelex- if applicable to your platform it will give you a performance boost in terms of speed.Below I outline some options that approximate
SVRand perform faster.To speed up support vector regression specifically, you could try running an algorithm that approximates it using a linear model. The snippet below approximates the effect of an RBF kernel using
Nystroem, and feeds those RBF features into aLinearSVR. Computation time forLinearSVRscales linearly with the number of samples, making it faster thanSVR.You can adjust these primary factors to trade accuracy for speed:
n_components=inNystroemNystroemwithRBFSampler(latter is generally faster but may be less accurate)tol=can also be increased to trade accuracy for speed. This also applies to various regularisation parameters.LinearSVRwithSGDRegressor(loss='epsilon_insensitive'). It might not converge as quickly, but it gives you another set of dials to tune if wanted.