老师您好:这个网格搜索GridSearchCV 中有个refit的设置,应该怎样填,
来源:4-6 网格搜索与k近邻算法中更多超参数
qq_慕姐45445
2021-06-24
from sklearn.decomposition import PCA
from sklearn import svm
from sklearn.model_selection import train_test_split
from sklearn.model_selection import GridSearchCV
from sklearn import metrics
regressor = svm.SVC()
parameters = {‘kernel’:[‘rbf’],
‘C’:[0.01,0.03,0.1,0.3,1,3,10],
‘gamma’:[1e-4,3e-4,1e-3,3e-3,0.01,0.03,0.1,0.3,1]}
clf = GridSearchCV(regressor,parameters,scoring=[‘roc_auc’],refit=‘roc_auc’,cv=10,n_jobs=-1)
clf.fit(np.array(train),np.array(target))
看了文档,也百度了,填refit='precision_score’也不对 填false,true,都不行都是报错
For multi-metric scoring, the parameter refit must be set to a scorer key or a callable to refit an estimator with the best parameter setting on the whole data and make the best_* attributes available for that metric. If this is not needed, refit should
应该怎么填啊,跪求帮助了
1回答
-
liuyubobobo
2021-06-24
试一下用这个例子:https://scikit-learn.org/stable/auto_examples/model_selection/plot_multi_metric_evaluation.html
注意,scoring 是一个 dictionary,refit 是这个 dictionary 中的一个 key。
继续加油!:)
012021-06-26
相似问题