scikit-learn: locally failing kmeans convergence test (WSL)

> pytest -sv sklearn/cluster/tests/test_k_means.py -k test_kmeans_convergence

fails for me for both algorithms:

>       assert km.n_iter_ < 300
E       AssertionError: assert 300 < 300
E        +  where 300 = KMeans(algorithm='full', n_clusters=5, n_init=1, random_state=0, tol=0).n_iter_

show_versions:

System:
    python: 3.8.3 (default, May 19 2020, 18:47:26)  [GCC 7.3.0]
executable: /home/andy/anaconda3/envs/sklearndev/bin/python
   machine: Linux-4.4.0-18362-Microsoft-x86_64-with-glibc2.10

Python dependencies:
          pip: 20.0.2
   setuptools: 46.4.0.post20200518
      sklearn: 0.24.dev0
        numpy: 1.18.1
        scipy: 1.4.1
       Cython: 0.29.17
       pandas: 1.0.3
   matplotlib: 3.1.3
       joblib: 0.15.1
threadpoolctl: 2.1.0

Built with OpenMP: True

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 18 (18 by maintainers)

Most upvoted comments

I don’t have a preference. I’m fine with both. I’d also be fine with silently switch to tol=eps when user provides tol=0 😃

Initially this test was added in a PR which goal was to make sure that when tol=0, the iteration loop don’t run until max_iter (due to strict inequality check before).

Since we can’t guarantee that due to floating point errors, I think we should just remove the test.