From c3d0eae19bf560156ba177a33af080334c8901d3 Mon Sep 17 00:00:00 2001 From: genvalen Date: Mon, 27 Feb 2023 01:51:38 -0500 Subject: [PATCH 1/4] Add function to function list. --- sklearn/tests/test_public_functions.py | 1 + 1 file changed, 1 insertion(+) diff --git a/sklearn/tests/test_public_functions.py b/sklearn/tests/test_public_functions.py index 4e13bb46ef645..d83f1260ca638 100644 --- a/sklearn/tests/test_public_functions.py +++ b/sklearn/tests/test_public_functions.py @@ -125,6 +125,7 @@ def _check_function_param_validation( "sklearn.metrics.hamming_loss", "sklearn.metrics.jaccard_score", "sklearn.metrics.log_loss", + "metrics.matthews_corrcoef", "sklearn.metrics.max_error", "sklearn.metrics.mean_absolute_error", "sklearn.metrics.mean_pinball_loss", From 590b880a45c55179933c2f18581f1f0deb8075f1 Mon Sep 17 00:00:00 2001 From: genvalen Date: Mon, 27 Feb 2023 02:00:27 -0500 Subject: [PATCH 2/4] Add function to function list. --- sklearn/tests/test_public_functions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sklearn/tests/test_public_functions.py b/sklearn/tests/test_public_functions.py index d83f1260ca638..585bef2d65556 100644 --- a/sklearn/tests/test_public_functions.py +++ b/sklearn/tests/test_public_functions.py @@ -125,7 +125,7 @@ def _check_function_param_validation( "sklearn.metrics.hamming_loss", "sklearn.metrics.jaccard_score", "sklearn.metrics.log_loss", - "metrics.matthews_corrcoef", + "sklearn.metrics.matthews_corrcoef", "sklearn.metrics.max_error", "sklearn.metrics.mean_absolute_error", "sklearn.metrics.mean_pinball_loss", From a44c47c1fce0d3221ce70a5dcc23c30a1c026832 Mon Sep 17 00:00:00 2001 From: genvalen Date: Tue, 28 Feb 2023 08:48:52 -0500 Subject: [PATCH 3/4] Add validation. --- sklearn/metrics/_classification.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/sklearn/metrics/_classification.py b/sklearn/metrics/_classification.py index f7d002ac23743..6d7515ce35794 100644 --- a/sklearn/metrics/_classification.py +++ b/sklearn/metrics/_classification.py @@ -885,6 +885,13 @@ def jaccard_score( return np.average(jaccard, weights=weights) +@validate_params( + { + "y_true": ["array-like", "sparse matrix"], + "y_pred": ["array-like", "sparse matrix"], + "sample_weight": ["array-like", None], + } +) def matthews_corrcoef(y_true, y_pred, *, sample_weight=None): """Compute the Matthews correlation coefficient (MCC). From 2544eec887bba9d49b8d048e16faed38024a6e66 Mon Sep 17 00:00:00 2001 From: jeremiedbb Date: Tue, 28 Feb 2023 15:08:52 +0100 Subject: [PATCH 4/4] sparse not allowed --- sklearn/metrics/_classification.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sklearn/metrics/_classification.py b/sklearn/metrics/_classification.py index b62cc0c5197cd..b51ef3189ae56 100644 --- a/sklearn/metrics/_classification.py +++ b/sklearn/metrics/_classification.py @@ -887,8 +887,8 @@ def jaccard_score( @validate_params( { - "y_true": ["array-like", "sparse matrix"], - "y_pred": ["array-like", "sparse matrix"], + "y_true": ["array-like"], + "y_pred": ["array-like"], "sample_weight": ["array-like", None], } ) @@ -912,10 +912,10 @@ def matthews_corrcoef(y_true, y_pred, *, sample_weight=None): Parameters ---------- - y_true : array, shape = [n_samples] + y_true : array-like of shape (n_samples,) Ground truth (correct) target values. - y_pred : array, shape = [n_samples] + y_pred : array-like of shape (n_samples,) Estimated targets as returned by a classifier. sample_weight : array-like of shape (n_samples,), default=None