Skip to content

Commit 5cf711a

Browse files
committed
TST finish to add invariance test for sample based metrics
1 parent 1aa0f07 commit 5cf711a

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

sklearn/metrics/tests/test_metrics.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@
179179
# When you add a new metric or functionality, check if a general test
180180
# is already written.
181181

182-
# Metric undefine with "binary" or "multiclass" input
182+
# Metric undefined with "binary" or "multiclass" input
183183
METRIC_UNDEFINED_MULTICLASS = [
184184
"samples_f0.5_score", "samples_f1_score", "samples_f2_score",
185185
"samples_precision_score", "samples_recall_score",
@@ -1377,6 +1377,8 @@ def test_format_invariance_with_1d_vectors():
13771377
y2_row = np.reshape(y2_1d, (1, -1))
13781378

13791379
for name, metric in ALL_METRICS.items():
1380+
if name in METRIC_UNDEFINED_MULTICLASS:
1381+
continue
13801382

13811383
measure = metric(y1, y2)
13821384

@@ -1447,8 +1449,7 @@ def test_invariance_string_vs_numbers_labels():
14471449
labels_str = ["eggs", "spam"]
14481450

14491451
for name, metric in CLASSIFICATION_METRICS.items():
1450-
if isinstance(metric, partial) and 'labels' in metric.keywords:
1451-
# don't test metric if "labels" are already set
1452+
if name in METRIC_UNDEFINED_MULTICLASS:
14521453
continue
14531454

14541455
measure_with_number = metric(y1, y2)

0 commit comments

Comments
 (0)