2

I am having a similar problem on this link: Parallel error with GridSearchCV, works fine with other methods

I tried both of the solutions and neither one worked for me, as well.

When n_jobs = -1 in a grid search I get an error although n_jobs = -1 works fine for single models.

I tried updating sklearn but it did not help.

Here is the code I am trying:

rf = RandomForestClassifier()
rf_random = RandomizedSearchCV(estimator=rf, 
                          param_distributions = random_grid,
                          n_iter = 100, cv = 3,  verbose = 2, random_state = 42, 
                          n_jobs = -1)
rf_random.fit(X_train, y_train)

I am getting this error:

ModuleNotFoundError: No module named 
'sklearn.externals.joblib.externals.loky.backend.popen_loky_win32'

Tried the solution on the link but got the same error:

def randomsearcher():
    clf = ensemble.RandomForestClassifier()
    param_grid = random_grid
    grid_s= model_selection.GridSearchCV(clf, cv=5,  param_grid=param_grid 
                                    ,n_jobs=-1,verbose=1)
    grid_s.fit(X_train,y_train)
    return grid_s

if __name__ == '__main__':
randomsearcher()

No problem with this code:

knn = KNeighborsClassifier(n_neighbors=50, 
weights='distance',algorithm='auto',n_jobs = -1 )

I am working on a VM that has 8 virtual processors on 2 sockets.

e_kapti
  • 61
  • 5

0 Answers0