From 312cad6c26128c213eab43bc28b5c810feb47c06 Mon Sep 17 00:00:00 2001 From: safikh Date: Sat, 3 Sep 2022 10:56:48 +0530 Subject: [PATCH] Fix docstring for adjusted_rand_score --- sklearn/metrics/cluster/_supervised.py | 41 +++++++++++++------------- sklearn/tests/test_docstrings.py | 1 - 2 files changed, 20 insertions(+), 22 deletions(-) diff --git a/sklearn/metrics/cluster/_supervised.py b/sklearn/metrics/cluster/_supervised.py index 5d650fcaae33b..2675c2164d184 100644 --- a/sklearn/metrics/cluster/_supervised.py +++ b/sklearn/metrics/cluster/_supervised.py @@ -335,10 +335,10 @@ def adjusted_rand_score(labels_true, labels_pred): Parameters ---------- labels_true : int array, shape = [n_samples] - Ground truth class labels to be used as a reference + Ground truth class labels to be used as a reference. labels_pred : array-like of shape (n_samples,) - Cluster labels to evaluate + Cluster labels to evaluate. Returns ------- @@ -346,6 +346,24 @@ def adjusted_rand_score(labels_true, labels_pred): Similarity score between -0.5 and 1.0. Random labelings have an ARI close to 0.0. 1.0 stands for perfect match. + See Also + -------- + adjusted_mutual_info_score : Adjusted Mutual Information. + + References + ---------- + .. [Hubert1985] L. Hubert and P. Arabie, Comparing Partitions, + Journal of Classification 1985 + https://link.springer.com/article/10.1007%2FBF01908075 + + .. [Steinley2004] D. Steinley, Properties of the Hubert-Arabie + adjusted Rand index, Psychological Methods 2004 + + .. [wk] https://en.wikipedia.org/wiki/Rand_index#Adjusted_Rand_index + + .. [Chacon] :doi:`Minimum adjusted Rand index for two clusterings of a given size, + 2022, J. E. Chacón and A. I. Rastrojo <10.1007/s11634-022-00491-w>` + Examples -------- Perfectly matching labelings have a score of 1 even @@ -379,25 +397,6 @@ def adjusted_rand_score(labels_true, labels_pred): >>> adjusted_rand_score([0, 0, 1, 1], [0, 1, 0, 1]) -0.5 - - References - ---------- - .. [Hubert1985] L. Hubert and P. Arabie, Comparing Partitions, - Journal of Classification 1985 - https://link.springer.com/article/10.1007%2FBF01908075 - - .. [Steinley2004] D. Steinley, Properties of the Hubert-Arabie - adjusted Rand index, Psychological Methods 2004 - - .. [wk] https://en.wikipedia.org/wiki/Rand_index#Adjusted_Rand_index - - .. [Chacon] :doi:`Minimum adjusted Rand index for two clusterings of a given size, - 2022, J. E. Chacón and A. I. Rastrojo <10.1007/s11634-022-00491-w>` - - - See Also - -------- - adjusted_mutual_info_score : Adjusted Mutual Information. """ (tn, fp), (fn, tp) = pair_confusion_matrix(labels_true, labels_pred) # convert to Python integer types, to avoid overflow or underflow diff --git a/sklearn/tests/test_docstrings.py b/sklearn/tests/test_docstrings.py index 2a989513eb0e7..7fe828708abe4 100644 --- a/sklearn/tests/test_docstrings.py +++ b/sklearn/tests/test_docstrings.py @@ -21,7 +21,6 @@ "sklearn.metrics._ranking.roc_curve", "sklearn.metrics.cluster._bicluster.consensus_score", "sklearn.metrics.cluster._supervised.adjusted_mutual_info_score", - "sklearn.metrics.cluster._supervised.adjusted_rand_score", "sklearn.metrics.cluster._supervised.entropy", "sklearn.metrics.cluster._supervised.fowlkes_mallows_score", "sklearn.metrics.pairwise.pairwise_distances_chunked",