Skip to content Skip to sidebar Skip to footer

Minibatchkmeans Overflowerror: Cannot Convert Float Infinity To Integer?

I am trying to find the right number of clusters, k, according to silhouette scores using sklearn.cluster.MiniBatchKMeans. from sklearn.cluster import MiniBatchKMeans from sklearn.

Solution 1:

Let's analyze your code:

  • for k in range(5) returns the following sequence:
    • 0, 1, 2, 3, 4
  • model = MiniBatchKMeans(n_clusters = k) inits model with n_clusters=k
  • Let's look at the first iteration:
    • n_clusters=0 is used
    • Within the optimization-code (look at the output):
    • int(np.log(n_clusters))
    • = int(np.log(0))
    • = int(-inf)
    • ERROR: no infinity definition for integers!
    • -> casting floating-point value of -inf to int not possible!

Setting n_clusters=0 does not make sense!

Post a Comment for "Minibatchkmeans Overflowerror: Cannot Convert Float Infinity To Integer?"