8000 ENH Simplify error message of get_scorer (#11738) · scikit-learn/scikit-learn@825cf09 · GitHub
[go: up one dir, main page]

Skip to content

Commit 825cf09

Browse files
qinhanmin2014rth
authored andcommitted
ENH Simplify error message of get_scorer (#11738)
1 parent 7ba7a4a commit 825cf09

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

doc/modules/model_evaluation.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ Usage examples:
105105
>>> model = svm.SVC()
106106
>>> cross_val_score(model, X, y, cv=5, scoring='wrong_choice')
107107
Traceback (most recent call last):
108-
ValueError: 'wrong_choice' is not a valid scoring value. Valid options are ['accuracy', 'adjusted_mutual_info_score', 'adjusted_rand_score', 'average_precision', 'balanced_accuracy', 'brier_score_loss', 'completeness_score', 'explained_variance', 'f1', 'f1_macro', 'f1_micro', 'f1_samples', 'f1_weighted', 'fowlkes_mallows_score', 'homogeneity_score', 'mutual_info_score', 'neg_log_loss', 'neg_mean_absolute_error', 'neg_mean_squared_error', 'neg_mean_squared_log_error', 'neg_median_absolute_error', 'normalized_mutual_info_score', 'precision', 'precision_macro', 'precision_micro', 'precision_samples', 'precision_weighted', 'r2', 'recall', 'recall_macro', 'recall_micro', 'recall_samples', 'recall_weighted', 'roc_auc', 'v_measure_score']
108+
ValueError: 'wrong_choice' is not a valid scoring value. Use sorted(sklearn.metrics.SCORERS.keys()) to get valid options.
109109

110110
.. note::
111111

sklearn/metrics/scorer.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,8 +216,8 @@ def get_scorer(scoring):
216216
scorer = SCORERS[scoring]
217217
except KeyError:
218218
raise ValueError('%r is not a valid scoring value. '
219-
'Valid options are %s'
220-
% (scoring, sorted(SCORERS.keys())))
219+
'Use sorted(sklearn.metrics.SCORERS.keys()) '
220+
'to get valid options.' % (scoring))
221221
else:
222222
scorer = scoring
223223
return scorer

0 commit comments

Comments
 (0)
0