网格搜索错误

Grid search error

我一直在尝试执行网格搜索,但似乎出了点问题。 我的代码是:

grid_search_0 = GridSearchCV(estimator=Pipeline([('vectorizer', CountVectorizer()), ('tfidf', TfidfTransformer()), ('clf', LinearSVC())]),
             param_grid={'C': 3**np.arange(-3, 3, dtype='float'),
                         'gamma': 3**np.arange(-6, 0, dtype='float'), },
             cv=10,
             scoring=make_scorer(roc_auc_score, needs_threshold=True),
             verbose=1,
             n_jobs=-1,)

我得到了错误

ImportError: [joblib] Attempting to do parallel computing without protecting your import on a system that does not support forking. To use parallel-computing in a script, you must protect your main loop using "if __name__ == '__main__'". Please see the joblib documentation on Parallel for more information

有没有人遇到过并解决过这个问题?我做错了什么?

这是错误消息建议的操作,这对您有用吗?

if __name__ == '__main__':

    grid_search_0 = GridSearchCV(estimator=Pipeline([('vectorizer', CountVectorizer()), ('tfidf', TfidfTransformer()), ('clf', LinearSVC())]),
             param_grid={'C': 3**np.arange(-3, 3, dtype='float'),
                         'gamma': 3**np.arange(-6, 0, dtype='float'), },
             cv=10,
             scoring=make_scorer(roc_auc_score, needs_threshold=True),
             verbose=1,
             n_jobs=-1)

有关为什么这很重要的更多信息,请参阅