202107301337 - 聚类算法mean-shift

# python算法库sklearn 官网
https://scikit-learn.org/stable/modules/generated/sklearn.cluster.MeanShift.html#sklearn.cluster.MeanShift

# 使用


# 结果
## 获取聚类点,及每个聚类下的点数
ms = MeanShift()      					# 创建聚类器
ms.fit(X)  			 					 # 执行聚类
labels = ms.labels_  					 # 每个点的标签,标签值是聚类中心的索引
cluster_centers = ms.cluster_centers_    # 聚类中心的点的集合,该索引即时labels索引 


**bandwidth**
RBF核函数使用的半径,如果未设置,默认调用sklearn.cluster.estimate_bandwidth估算
# 自定义半径(带宽)
bandwidth = estimate_bandwidth(X, quantile=0.3)  
##设置均值偏移函数  
#ms = MeanShift(bandwidth=bandwidth, bin_seeding=True)
quantile参数
	That this function takes time at least quadratic in n_samples. For large  datasets, it's wise to set that parameter to a small value.
    quantile : float, default=0.3
	should be between [0, 1]
	0.5 means that the median of all pairwise distances is used.

能否指定半径为两千米
(1)更改计算距离函数,
参考https://www.cnblogs.com/wanghuaijun/p/6264000.html
(2)设置半径为两千米


posted @ 2025-03-19 22:07  钱塘江畔  阅读(19)  评论(0)    收藏  举报