本文整理汇总了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)