Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX ‘sparse’ kwarg was not used by fowlkes_mallows_score #28981

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions sklearn/metrics/cluster/_supervised.py
Original file line number Diff line number Diff line change
Expand Up @@ -1181,7 +1181,7 @@ def normalized_mutual_info_score(
},
prefer_skip_nested_validation=True,
)
def fowlkes_mallows_score(labels_true, labels_pred, *, sparse=False):
def fowlkes_mallows_score(labels_true, labels_pred, *, sparse=True):
"""Measure the similarity of two clusterings of a set of points.

.. versionadded:: 0.18
Expand Down Expand Up @@ -1212,7 +1212,7 @@ def fowlkes_mallows_score(labels_true, labels_pred, *, sparse=False):
labels_pred : array-like of shape (n_samples,), dtype=int
A clustering of the data into disjoint subsets.

sparse : bool, default=False
sparse : bool, default=True
Compute contingency matrix internally with sparse matrix.

Returns
Expand Down Expand Up @@ -1251,7 +1251,7 @@ def fowlkes_mallows_score(labels_true, labels_pred, *, sparse=False):
labels_true, labels_pred = check_clusterings(labels_true, labels_pred)
(n_samples,) = labels_true.shape

c = contingency_matrix(labels_true, labels_pred, sparse=True)
c = contingency_matrix(labels_true, labels_pred, sparse=sparse)
c = c.astype(np.int64, copy=False)
tk = np.dot(c.data, c.data) - n_samples
pk = np.sum(np.asarray(c.sum(axis=0)).ravel() ** 2) - n_samples
Expand Down
Loading