相关疑难解决方法(0)

在 GridSearchCV 中使用精度作为评分时如何指定正标签

model = sklearn.model_selection.GridSearchCV(
        estimator = est, 
        param_grid = param_grid,
        scoring = 'precision',
        verbose = 1,
        n_jobs = 1,
        iid = True,
        cv = 3)
Run Code Online (Sandbox Code Playgroud)

在 中sklearn.metrics.precision_score(y, y_pred,pos_label=[0]),我可以指定正标签,如何在 GridSearchCV 中也指定它?

如果无法指定,使用自定义评分时,如何定义?

我试过这个:

custom_score = make_scorer(precision_score(y, y_pred,pos_label=[0]),  
                          greater_is_better=True)  
Run Code Online (Sandbox Code Playgroud)

但我有错误:

NameError: name 'y_pred' is not defined
Run Code Online (Sandbox Code Playgroud)

scoring scikit-learn grid-search

5
推荐指数
1
解决办法
1574
查看次数

标签 统计

grid-search ×1

scikit-learn ×1

scoring ×1