Last answered:

09 Feb 2023

Posted on:

15 Oct 2022

0

Cannot reproduce output for the loop that saves the WCSS for any number of clusters

The following code produces an AttributeError at kmeans.fit(x): (AttributeError: 'NoneType' object has no attribute 'split'). The same error also appears with the jupyter notebook solution downloaded from the resources. How do I solve this error?

wcss = []
for i in range(1,7):
  kmeans = KMeans(i)
  kmeans.fit(x)
  wcss_iter = kmeans.inertia_
  wcss.append(wcss_iter)

2 answers ( 0 marked as helpful)
Posted on:

15 Oct 2022

2

Seems the issue is with conda using an outdated version of threadpoolctl.

Solve this by running pip install --upgrade threadpoolctl, then restarting your notebook kernel and run everything again.

I'm surprised Python has so many dependency errors, I thought these kind of errors were usually JS and npm territory ^^

Posted on:

09 Feb 2023

0

I have the same error, you can fix it by changing the range to (2,7).

Maybe there was a change in the library, and KMeans (1) isn't working any more, as does not make a lot of sense.

Submit an answer