Skip to content

Commit

Permalink
Adjust test_kmeans to avoid false positive failures (#6193)
Browse files Browse the repository at this point in the history
Before this, we would fail when cuML KMeans achieved a better score than scikit-learn by the margin.

Authors:
  - Dante Gama Dessavre (https://github.com/dantegd)

Approvers:
  - William Hicks (https://github.com/wphicks)

URL: #6193
  • Loading branch information
dantegd authored Dec 20, 2024
1 parent 0563a85 commit 5bc1328
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions python/cuml/cuml/tests/test_kmeans.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ def test_weighted_kmeans(nrows, ncols, nclusters, max_weight, random_state):
sk_kmeans.fit(cp.asnumpy(X), sample_weight=wt)
sk_score = sk_kmeans.score(cp.asnumpy(X))

assert abs(cu_score - sk_score) <= cluster_std * 1.5
assert cu_score - sk_score <= cluster_std * 1.5


@pytest.mark.parametrize("nrows", [1000, 10000])
Expand Down Expand Up @@ -418,5 +418,6 @@ def test_fit_transform_weighted_kmeans(
sk_transf = sk_kmeans.fit_transform(cp.asnumpy(X), sample_weight=wt)
sk_score = sk_kmeans.score(cp.asnumpy(X))

assert abs(cu_score - sk_score) <= cluster_std * 1.5
# we fail if cuML's score is significantly worse than sklearn's
assert cu_score - sk_score <= cluster_std * 1.5
assert sk_transf.shape == cuml_transf.shape

0 comments on commit 5bc1328

Please sign in to comment.