Python: Failed to import KMeans library; Kmeans error report and solution; NameError: name 'KMeans' is not defined

Python: Failed to import KMeans library; Kmeans error report and solution; NameError: name 'KMeans' is not defined

When we use the KMeans package for clustering in python, we get an error:

NameError: name 'KMeans' is not defined

The reason is that the package is not imported:

from sklearn.cluster import KMeans

At the same time, load the sklearn package in sertting . Remember not to load the KMeans package!


 

Guess you like

Origin blog.csdn.net/m0_52625549/article/details/124769749