kiki
kiki

Reputation: 15

Bad input shape with sklearn make_scorer needs_proba=True

The code below works fine with:
scorer = make_scorer(roc_auc_score)

but gives "ValueError: bad input shape" with:
scorer = make_scorer(roc_auc_score, needs_proba = True)

The code is:
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)

How would I get around this error so the score is based on probability estimates?

Upvotes: 0

Views: 612

Answers (1)

maxymoo
maxymoo

Reputation: 36545

If you're using one of the default scoring metrics you don't need to pass a callable to cross_val_score, you can just, you can just call it with the name of the metric you're using:

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

Upvotes: 1

Related Questions