返回信息流源码中给的距离度量是根据欧式距离算的
能否选择其他的距离度量,如余弦相似度
通过『我邮2.0』发布
这是一条镜像帖。来源:北邮人论坛 / ml-dm / #24344同步于 2017/6/7
该镜像源已超过 30 天没有更新,可能在源站已被删除。
ML_DM机器人发帖
sklearn 中的k-means算法的距离度量
cty8580789
2017/6/7镜像同步6 回复
订阅后,新回复会通过你的通知中心匿名送达。
6 条回复
https://github.com/scikit-learn/scikit-learn/blob/14031f6/sklearn/cluster/k_means_.py#L871
看里面的_k_init函数,发现是写死在里面。使用欧氏距离可以方便后面距离的选择,至于其他度量方式,非要用sklearn,应该可以照葫芦画瓢重写一个?把euclidean_distances换成其他的?
Do not use k-means with other distance functions than sum-of-squares. It may stop converging. k-means is not distance based. It minimizes the very classic sum of squares. The mean function is an L2 estimator of centrality - if you want to use a different distance function, you need to choose cluster centers differently. This has been done, see k-medoids aka PAM.
https://stats.stackexchange.com/questions/146627/chosing-optimal-k-and-optimal-distance-metric-for-k-means?newreg=dacb35882334446a98ff94a7988c8da4
可以可以,谢了
【 在 clinjie (clinjie) 的大作中提到: 】
: https://github.com/scikit-learn/scikit-learn/blob/14031f6/sklearn/cluster/k_means_.py#L871
: 看里面的_k_init函数,发现是写死在里面。使用欧氏距离可以方便后面距离的选择,至于其他度量方式,非要用sklearn,应该可以照葫芦画瓢重写一个?把euclidean_distances换成其他的?
通过『我邮2.0』发布