当前位置: 首页>>代码示例>>Python>>正文


Python MeanShift.min_bin_freq方法代码示例

本文整理汇总了Python中sklearn.cluster.MeanShift.min_bin_freq方法的典型用法代码示例。如果您正苦于以下问题:Python MeanShift.min_bin_freq方法的具体用法?Python MeanShift.min_bin_freq怎么用?Python MeanShift.min_bin_freq使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sklearn.cluster.MeanShift的用法示例。


在下文中一共展示了MeanShift.min_bin_freq方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: open

# 需要导入模块: from sklearn.cluster import MeanShift [as 别名]
# 或者: from sklearn.cluster.MeanShift import min_bin_freq [as 别名]
json_data=open('config').read()
data = json.loads(json_data)

train_data_file = data['train']
train_data = open(train_data_file)

# location contains longitude and latitude of an image
location_in_degrees = [(line.split()[-2],line.split()[-1]) for line in train_data.xreadlines()]
location_list = [(utility.convert_to_cartesian(float(loc[0]), float(loc[1]), float(6371)))
                for loc in location_in_degrees]

location = numpy.zeros(shape=(len(location_list),3))

location_arr = numpy.array(location_list)

for i in range(len(location_arr)):
    location[i][0] = location_arr[i][0]
    location[i][1] = location_arr[i][1]
    location[i][2] = location_arr[i][2]

# The following bandwidth can be automatically detected using
bandwidth = estimate_bandwidth(location, quantile=0.2, n_samples=500)
ms = MeanShift(bandwidth=bandwidth, bin_seeding=True)
ms.min_bin_freq = 250
ms.fit(location)
labels = ms.labels_
cluster_centers = ms.cluster_centers_


print labels
print len(cluster_centers)
开发者ID:sumehta,项目名称:ContextSlices,代码行数:33,代码来源:cluster.py


注:本文中的sklearn.cluster.MeanShift.min_bin_freq方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。