8000 More informative error message for classification metrics given regre… · scikit-learn/scikit-learn@f99fd0d · GitHub
[go: up one dir, main page]

Skip to content

Commit f99fd0d

Browse files
jnothmanjmschrei
authored andcommitted
More informative error message for classification metrics given regression output (#9275)
1 parent 0cdd91d commit f99fd0d

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

sklearn/metrics/classification.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ def _check_targets(y_true, y_pred):
7777
y_type = set(["multiclass"])
7878

7979
if len(y_type) > 1:
80-
raise ValueError("Can't handle mix of {0} and {1}"
81-
"".format(type_true, type_pred))
80+
raise ValueError("Classification metrics can't handle a mix of {0} "
81+
"and {1} targets".format(type_true, type_pred))
8282

8383
# We can't have more than one value on y_type => The set is no more needed
8484
y_type = y_type.pop()

sklearn/metrics/tests/test_classification.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1344,7 +1344,8 @@ def test__check_targets():
13441344
if type1 != type2:
13451345
assert_raise_message(
13461346
ValueError,
1347-
"Can't handle mix of {0} and {1}".format(type1, type2),
1347+
"Classification metrics can't handle a mix of {0} and {1} "
1348+
"targets".format(type1, type2),
13481349
_check_targets, y1, y2)
13491350

13501351
else:

sklearn/metrics/tests/test_common.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -636,7 +636,8 @@ def test_inf_nan_input():
636636
for metric in CLASSIFICATION_METRICS.values():
637637
for y_true, y_score in invalids:
638638
assert_raise_message(ValueError,
639-
"Can't handle mix of binary and continuous",
639+
"Classification metrics can't handle a mix "
640+
"of binary and continuous targets",
640641
metric, y_true, y_score)
641642

642643

0 commit comments

Comments
 (0)
0