我正在尝试为我运行的 K-Means 模型绘制轮廓图,但是,我得到了错误:ImportError: cannot import name 'safe_indexing' from 'sklearn.utils
.
我最初在这里遇到了这篇文章中描述的 NotFoundError 问题,但是一旦我修复了它,我就遇到了这个问题。我的代码如下:
from yellowbrick.cluster import SilhouetteVisualizer
fig, ax = plt.subplots(2, 2, figsize=(15,8))
for i in range(1,6):
kmeans = KMeans(n_clusters=i, init='k-means++', n_init=10, max_iter=100, random_state=0)
q, mod = divmod(i, 2)
visualizer = SilhouetteVisualizer(km, colors='yellowbrick', ax=ax[q-1][mod])
visualizer.fit(ct1)