I am trying to use the GridSearchCV to evaluate different models with different parameter sets. Logistic Regression and k-NN do not cause a problem but Decision Tree, Random Forest and some of the other types of classifiers do not work when n_jobs=-1.
for classifier, paramSet, classifierName in zip(list_classifiers, list_paramSets, list_clfNames):
gs = GridSearchCV(
estimator = classifier,
param_grid = paramSet,
cv = 10,
n_jobs = -1
)
gs.fit(X_train, y_train)
plot_learning_curve(gs, "Learning Curve", X_train, y_train, n_jobs=-1)
I am working on Google Colab and either of the solution proposals below did not solve my problem.
from sklearn.externals.joblib import parallel_backend
clf = GridSearchCV(...)
with parallel_backend('threading',n_jobs = -1):
clf.fit(x_train, y_train)
if __name__ == "__main__":
import multiprocessing as mp; mp.set_start_method('forkserver', force=True) // 'spawn' has also failed
/// Gridsearch and fit here ///
Here is my source code : https://github.com/bahadirbasaran/pulsarDetection/blob/master/main.ipynb
The error log:
Any help will be appreciated!
