报错一、
sklearn Kmeans聚类算法遇到的错误
py:870: FutureWarning: The default value of n_init will change from 10 to ‘auto’ in 1.4. Set the value of n_init explicitly to suppress the warning warnings.warn(
原因
sklearn 1.4版更新
解决方法
在模型后添加 n_init='auto' 即可
kmeans=KMeans(n_clusters=10,n_init='auto')
报错二、
问题遇到的现象
错误:UserWarning: KMeans is known to have a memory leak on Windows with MKL, when there are less chunks than available threads. You can avoid it by setting the environment variable OMP_NUM_THREADS=15.
原因
使用KMeans拟合数据的时候出现警告。由于可能是数据量太大,然后出现这个情况,但是数据量很少的时候也会出现这个警告。
解决方法
在文件开头添加如下:
import os
os.environ["OMP_NUM_THREADS"] = '1'