kmeans cluster Newbie



我是Python的新手,正在运行集群介绍演示。然而,代码一度被卡住,我希望有人能帮我解决这个问题。

# Import the library
from sklearn.cluster import KMeans# To make sure our work becomes reproducible
np.random.seed(42)inertia = []# Iterating the process
for i in range(2, 10):
# Instantiate the model
model = KMeans(n_clusters=i)
# Fit The Model
model.fit(X_transformed)
# Extract the error of the model
inertia.append(model.inertia_)# Visualize the model
sns.pointplot(x=list(range(2, 10)), y=inertia)
plt.title('SSE on K-Means based on # of clusters')
plt.show()

这是我得到的错误消息:

File "<ipython-input-32-95dac55492e9>", line 3
np.random.seed(42)inertia = []# Iterating the process
^
SyntaxError: invalid syntax

非常感谢

惯性应该是新的线

from sklearn.cluster import KMeans# To make sure our work becomes reproducible
np.random.seed(42)
inertia = []# Iterating the process

相关内容

  • 没有找到相关文章

最新更新