我是 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
非常感谢