Python:导入KMeans库失败;Kmeans报错及解决方法;NameError: name ‘KMeans‘ is not defined

Python:导入KMeans库失败;Kmeans报错及解决方法;NameError: name 'KMeans' is not defined

当我们在python中使用KMeans包进行聚类时报错:

NameError: name 'KMeans' is not defined

原因是没有导入包:

from sklearn.cluster import KMeans

同时在sertting中加载sklearn包即可。切记不是加载KMeans包!

Python:导入KMeans库失败;Kmeans报错及解决方法;NameError: name ‘KMeans‘ is not defined_第1张图片
 

你可能感兴趣的:(python,python,kmeans,sklearn)