python报错ImportError: [joblib] Attempting to do parallel computing without protecting

来源:互联网 发布:柳海龙 知乎 编辑:程序博客网 时间:2024/05/17 04:30

这里写图片描述
错误:
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

解决方案:

from sklearn.grid_search import GridSearchCVif __name__=='__main__'://加入此行代码即可    Cs=np.logspace(-6,-1,10)    clf=GridSearchCV(estimator=svc,param_grid=dict(C=Cs),n_jobs=-1)    clf.fit(X_digits[:1000],Y_digits[:1000])    print (clf.best_score_)    print (clf.best_estimator_.C)    print (clf.score(X_digits[1000:],Y_digits[1000:]))

这里写图片描述

0 0
原创粉丝点击