Skip to content

TST Ensure that sklearn/cluster/tests/test_k_means.py is seed insensitive #23388

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

Merged

Conversation

ShoaibKhan
Copy link
Contributor

@ShoaibKhan ShoaibKhan commented May 16, 2022

Reference Issues/PRs

towards #22827

What does this implement/fix? Explain your changes.

This upgrades the k_means tests to account for greater randomness using global_random_seed.

Any other comments?

Some tests were left unchanged, as suggested in the original issue, as they don't test mathematical properties. Many tests failed with the introduction of randomness and to fix this, they were left as is.

test_kmeans_elkan_results
test_kmeans_convergence
test_minibatch_update_consistency
test_fortran_aligned_data
test_minibatch_sensible_reassign
test_minibatch_reassign
test_score_max_iter
test_dense_sparse
test_transform
test_fit_transform
test_n_init
test_k_means_function
test_float_precision
test_weighted_vs_repeated
test_unit_weights_vs_no_weights
test_scaled_weights
test_result_equal_in_diff_n_threads
test_k_means_1_iteration
test_euclidean_distance
test_inertia
test_kmeans_plusplus_output
test_kmeans_plusplus_dataorder
Copy link
Member

@jeremiedbb jeremiedbb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR @ShoaibKhan. I synced with main and fixed the linting issues. LGTM.

@jeremiedbb jeremiedbb merged commit 6ebdce7 into scikit-learn:main Sep 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants