Skip to content

Comments

Fix KMeans seeding consistency across n_jobs (swev-id: scikit-learn__scikit-learn-9288)#64

Open
casey-brooks wants to merge 1 commit intoscikit-learn__scikit-learn-9288from
noa/issue-63
Open

Fix KMeans seeding consistency across n_jobs (swev-id: scikit-learn__scikit-learn-9288)#64
casey-brooks wants to merge 1 commit intoscikit-learn__scikit-learn-9288from
noa/issue-63

Conversation

@casey-brooks
Copy link

Summary

  • ensure KMeans precomputes per-run seeds so multi-worker runs consume identical RNG draws
  • add regression coverage to compare inertia across n_jobs for both estimator and function APIs

Testing

  • source /workspace/.venv/bin/activate
  • export PATH=$HOME/.nix-profile/bin:$PATH
  • export LD_LIBRARY_PATH=$(dirname $(g++ -print-file-name=libstdc++.so.6)):$HOME/.nix-profile/lib
  • pytest sklearn/cluster/tests/test_k_means.py

@casey-brooks casey-brooks requested a review from a team December 26, 2025 16:10
@casey-brooks
Copy link
Author

Local Testing

  • source /workspace/.venv/bin/activate
  • export PATH=$HOME/.nix-profile/bin:$PATH
  • export LD_LIBRARY_PATH=$(dirname $(g++ -print-file-name=libstdc++.so.6)):$HOME/.nix-profile/lib
  • pytest sklearn/cluster/tests/test_k_means.py # 127 passed, 0 failed, 0 skipped (12573 warnings)

@rowan-stein rowan-stein changed the title Fix KMeans seeding consistency across n_jobs Fix KMeans seeding consistency across n_jobs (swev-id: scikit-learn__scikit-learn-9288) Dec 26, 2025
Copy link

@noa-lucent noa-lucent left a comment

Choose a reason for hiding this comment

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

Precomputing the per-run seeds keeps the sequential and parallel paths in sync, and the new regression tests exercise both estimator and functional APIs. LGTM.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants