I am writing code to perform nested CV in Python, by using scikit-learn library. My code core is the following:
pipe = Pipeline([('scl', StandardScaler()), ('reduce_dim', PCA()), ('myest', xgb.XGBRegressor())]) # Create my own pipeline to train and test
clf = GridSearchCV(pipe, param_grid=p_grid, cv=inner_cv, refit=True, scoring = my_corrcoef_scorer) #scoring = 'neg_mean_absolute_error' # GridSearchCV for the inner loops
nested_score = cross_validate(clf, X=X, y=y, cv=outer_cv, return_train_score=True, return_estimator=True, scoring = my_corrcoef_scorer) #scoring = 'neg_mean_absolute_error' # cross_validate for the outer loops
I would like to run my code on a Linux (Centos 7) machine, equipped with 32 CPUs, using more than one core. Unfortunately, I read the following sentence from scikit-learn official documentation: Warning You cannot nest objects with parallel computing (n_jobs different than 1).
What does exactly mean? If I write n_jobs = -1 (or > 1), the results will be wrong?
I ran my code multiple times, changing the n_jobs values in GridSearchCV (inner loop) and/or cross_validate (outer loop), but the results were equal..What am I missing?
Thanks for any answer!