<jupyter_start><jupyter_text>聚类评估指标  真实标签已知可以采用互信息分，V-meansure，兰德系数进行评价 真实标签未知 轮廓系数（评价簇内差异与簇外差异的关系）取值在-1到1之间，越接近1表示簇内越相似<jupyter_code>from sklearn.metrics import silhouette_score
from sklearn.metrics import silhouette_samples
silhouette_score(x,y_pred)# 分四簇时的结果
silhouette_samples(x,y_pred)<jupyter_output><empty_output><jupyter_text>卡林斯基-哈拉巴斯指数（CHI）越高越好<jupyter_code>import sklearn
print("Sklearn verion is {}".format(sklearn.__version__))
from sklearn.metrics import calinski_harabasz_score
calinski_harabasz_score(x, y_pred)
# 查看那CHI计算的时间
from time import time
t0 = time()
calinski_harabasz_score(x, y_pred)
time() - t0
import datetime
datetime.datetime.fromtimestamp(t0).strftime("%Y-%m-%d %H:%M:%S")<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.10899182561307902, 'fraction_numerical': 0.008174386920980926, 'mean_word_length': 11.672413793103448, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '98330', 'license': 'MIT', 'n_tokens_mistral': 365, 'n_tokens_neox': 392, 'n_words': 40, 'path': 'code/clusting/kmeans.ipynb', 'repo_name': 'Knowledge-Precipitation-Tribe/Machine-Learning', 'size': '734'}