def evaluate_kmeans(X, model):
""" Evaluate a K-Means model that has been trained on X using the
Silhouette score.
Args:
X: the TF-IDF matrix where each line represents a document and each
column represents a word, typically obtained by running
transform_text() from the TP2.
model: the KMeans model trained on X.
Returns:
A double that corresponds to the Silhouette score of the model.
"""
return silhouette_score(X, model.labels_)
# Ex2
评论列表
文章目录