• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

scikit-learn / scikit-learn / 22560
17%

Build:
DEFAULT BRANCH: master
Ran 30 Nov 2016 01:10AM UTC
Jobs 1
Files 368
Run time 27s
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

pending completion
22560

push

travis-ci

jnothman
[MRG+2] Fix K Means init center bug (#7872)

K-Means: Subtract X_means from initial centroids iff it's also subtracted from X

The bug happens when X is sparse and initial cluster centroids are
given. In this case the means of each of X's columns are computed and
subtracted from init for no reason.

To reproduce:

   import numpy as np
   import scipy
   from sklearn.cluster import KMeans
   from sklearn import datasets

   iris = datasets.load_iris()
   X = iris.data

   '''Get a local optimum'''
   centers = KMeans(n_clusters=3).fit(X).cluster_centers_

   '''Fit starting from a local optimum shouldn't change the solution'''
   np.testing.assert_allclose(
      centers,
      KMeans(n_clusters=3, init=centers, n_init=1).fit(X).cluster_centers_
   )

   '''The same should be true when X is sparse, but wasn't before the bug fix'''
   X_sparse = scipy.sparse.csr_matrix(X)
   np.testing.assert_allclose(
      centers,
      KMeans(n_clusters=3, init=centers, n_init=1).fit(X_sparse).cluster_centers_
   )

56937 of 60132 relevant lines covered (94.69%)

0.95 hits per line

Jobs
ID Job ID Ran Files Coverage
1 22560.1 (DISTRIB="ubuntu" PYTHON_VERSION="2.7" CYTHON_VERSION="0.23.4" COVERAGE=true) 30 Nov 2016 01:10AM UTC 0
94.69
Travis Job 22560.1
Source Files on build 22560
Detailed source file information is not available for this build.
  • Back to Repo
  • Travis Build #22560
  • 89b2e45c on github
  • Prev Build on master (#22553)
  • Next Build on master (#22562)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc