I am encounteringt the following problems using GridSearchCV: it gives me a parallel error while using n_jobs > 1
. At the same time n_jobs > 1
wo
I think you are using windows. You need to wrap the grid search in a function and then call inside __name__ == '__main__'
. Joblib parallel n_jobs=-1
determines the number of jobs to use which in parallel doesn't work on windows all the time.
Try wrapping grid search in a function:
def somefunction():
clf = ensemble.RandomForestClassifier()
param_grid = {'n_estimators': [10,20]}
grid_s= model_selection.GridSearchCV(clf, param_grid=param_grid_gb,n_jobs=-1,verbose=1)
grid_s.fit(train, targ)
return grid_s
if __name__ == '__main__':
somefunction()
Or:
if __name__ == '__main__':
clf = ensemble.RandomForestClassifier()
param_grid = {'n_estimators': [10,20]}
grid_s= model_selection.GridSearchCV(clf, param_grid=param_grid_gb,n_jobs=-1,verbose=1)
grid_s.fit(train, targ)