相关代码:
from sklearn.metrics import fowlkes_mallows_score
fmi_score=fowlkes_mallows_score(bidding_target_train,kmeans.labels_)
fmi_score
警告内容:
E:\ProgramData\Anaconda3\lib\site-packages\sklearn\metrics\cluster\supervised.py:859: RuntimeWarning: overflow encountered in int_scalars
return tk / np.sqrt(pk * qk) if tk != 0. else 0.
分母为0吗?聚类算法的参数发来瞅瞅
这个警告使用 fowlkes_mallows_score
函数时遇到了数值上溢的问题,这可能导致函数结果不精确或超出预期的范围。溢出可以发生在分子或分母上,这里的警告提示出现在计算适度特征值(Moderate Purity)时,即在计算 FMI 分数时。如果函数结果不在 [0,1] 的范围之间,可能是由于这个数值溢出所导致的。
尝试使用以下方法解决这个问题:
Decimal
。