[英]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
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.