Issue
I am running a GridSearchCV on a KneighborsClassifier and put the n_jobs hyperparameter on -1 , so all my CPU's are utilized for the gridsearch. So intuitively I think there should be 8 different combinations of hyperparameters being run parallel.
During the run using htop on ubuntu I can see that all 8 of my CPU's are being 99% used by python, so it looks as to be expected. But jupyter outputs during the run
[Parallel(n_jobs=1)]: Using backend SequentialBackend with 1 concurrent workers.
And from what I can tell from the code output, it looks like everything is being executed serial instead of parallel.
So what is exactly going on here?
EDIT: The code
from sklearn.model_selection import GridSearchCV
param_grid_knn=[
{
'weights' : ['uniform','distance'],
'n_jobs' : [-1],
'n_neighbors' : [3,5,7],
'p' :[1,2]
}
]
knn = KNeighborsClassifier()
grid_search = GridSearchCV(knn,param_grid_knn,cv=5,scoring='accuracy',return_train_score=True,verbose=2,refit=True)
grid_search.fit(train_data,train_labels)
Solution
I found the answer, the n_jobs=1 refers to the n_jobs used by GridSearchCV, which by default is 1 since I didn't specify it in its function call.
Answered By - BURNS
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.