Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/307.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/silverlight/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 包含3-4个特征的用户定义数据聚类的meanshift算法_Python_Machine Learning_Scikit Learn_Pattern Recognition_Mean Shift - Fatal编程技术网

Python 包含3-4个特征的用户定义数据聚类的meanshift算法

Python 包含3-4个特征的用户定义数据聚类的meanshift算法,python,machine-learning,scikit-learn,pattern-recognition,mean-shift,Python,Machine Learning,Scikit Learn,Pattern Recognition,Mean Shift,我想对由对象名称、x_坐标、y_坐标和相应温度组成的数据进行聚类。尝试均方聚类算法,根据位置和附近温度对附近对象进行聚类,即识别冷热区域。下面是代码和小样本数据。但默认情况下,它只提供单个集群设置,但无法显示图形。我想知道以下代码中可能有什么错误: import numpy as np from mpl_toolkits.mplot3d import Axes3D import pandas as pd from sklearn.decomposition import PCA

我想对由对象名称、x_坐标、y_坐标和相应温度组成的数据进行聚类。尝试均方聚类算法,根据位置和附近温度对附近对象进行聚类,即识别冷热区域。下面是代码和小样本数据。但默认情况下,它只提供单个集群设置,但无法显示图形。我想知道以下代码中可能有什么错误:

import numpy as np  
from mpl_toolkits.mplot3d import Axes3D  
import pandas as pd  
from sklearn.decomposition import PCA    
from sklearn.cluster import MeanShift, estimate_bandwidth  
import matplotlib.pyplot as plt  
from itertools import cycle  

data = pd.read_csv("data.csv")

centers = [[1, 1, 1], [0,0,0], [0,0,0]]  
X= data._get_numeric_data()  
bandwidth = estimate_bandwidth()  

ms = MeanShift()  
ms.fit(X)  
labels = ms.labels_  
cluster_centers = ms.cluster_centers_  

print labels  
print cluster_centers  

fig = plt.figure()  
ax = plt.axes(projection='3d')  
x = data['x_cordinate']  
y=data['y_cordinate']  
z=data['tpa']  
c=labels  
ax.scatter(x,y,z, c=c)  
plt.show()  
Data.csv:

名称,x_cordinate,y_cordinate,温度
CTRS351892006859000,0.3998434286
CTRS451733606812800,0.4779542857
CTRS556604406812800,0.7044195918
CSTR319354005929720,0
CSTRS419538805929720,0
CSTR54913202689120,0
CLTRS334362405884840,0.3998434286
CLTRS432963205884840,0.4779542857

CLTRS554268005725120,0.7044195918

估计带宽需要一个参数(您的数据)。这个代码运行吗

无论如何。。。当这种情况发生在我身上时,我为
estimate\u bandwidth
给出的
quantile
参数值小于默认值0.3(并将带宽估计值传递给MeanShift构造函数!)


你也可能事先知道一个好的带宽,如果你知道的话,最好使用它。

是的,我也尝试过使用默认值,并将值更改为0.5,它运行了大约20个小时,只给出了一个集群如何发布你实际使用的代码和数据?由于语法错误,上面的代码无法运行;由于estimate_bandwidth以500项为一批工作(您提供了9项),因此无法在修复语法错误的情况下运行;由于代码显示部分中的列名称错误,无法在直接向MeanShift构造函数(1.5e6)提供合理带宽后运行。我已经没有热情了,或者我要指出的是,您的数据比例很差(x和y与温度比例),无法直接用于meanshift或KMeans等距离方法。如果您提供电子邮件或云存储库id,或者通过任何其他方式,我可以共享,则查看数据文件太大,无法共享。关于kmeans,数据可以用n个聚类数进行聚类,但我也试图通过均值漂移、kmeans和基于密度的算法来找出聚类的确切差异