【问题标题】:Bad input shape with sklearn make_scorer needs_proba=Truesklearn make_scorer needs_proba=True 的错误输入形状
【发布时间】:2016-12-18 18:29:07
【问题描述】:

以下代码适用于:
scorer = make_scorer(roc_auc_score)

但给出“ValueError: bad input shape”:
scorer = make_scorer(roc_auc_score, needs_proba = True)

代码是:
clf = GaussianNB() cv = ShuffleSplit(features.shape[0], n_iter = 10, test_size = 0.2, random_state = 0) scorer = make_scorer(roc_auc_score, needs_proba = True) score = cross_val_score(clf, features, labels, cv=cv, scoring=scorer)

如何绕过这个错误,以便分数基于概率估计?

【问题讨论】:

    标签: python machine-learning scikit-learn


    【解决方案1】:

    如果您使用的是默认评分指标之一,您不需要通过一个可调用的cross_val_score,您只能用您使用的度量标准称为:

    score = cross_val_score(clf, features, labels, cv=cv, scoring='roc_auc_score')
    

    【讨论】:

    • 谢谢@maxymoo! score = cross_val_score(clf, features, labels, cv=cv, scoring='roc_auc') @工作很好。 span>
    猜你喜欢
    • 2020-01-04
    • 2018-01-27
    • 2018-04-06
    • 2017-12-21
    • 1970-01-01
    • 1970-01-01
    • 2018-10-23
    • 2021-12-20
    • 2019-04-08
    相关资源
    最近更新 更多