我有一个包含两个参数的数据集,如下所示(我添加了密度等值线图):
我的目标是将这个样本分成两个子集,如下所示:
这张图片来自SDSS中恒星形成的淬火组:中心,卫星和星系一致性,Knobel等人,《天体物理学杂志》,800:24(20pp),2015年2月1日,可查阅here。这个 分隔线是用眼睛画的,并不完美。你知道吗
我需要的是像这张漂亮的维基百科图表中的红线(最大化距离):
不幸的是,所有的线性分类,似乎接近我要找的(支持向量机,SVC等)是监督学习。你知道吗
我尝试过无监督学习,比如KMeans 2 clusteers,这种方式(CompactSFR[['lgm_tot_p50','sSFR']]
是您可以在本文末尾找到的熊猫数据集):
X = CompactSFR[['lgm_tot_p50','sSFR']]
from sklearn.cluster import KMeans
kmeans2 = KMeans(n_clusters=2)
# Fitting the input data
kmeans2 = kmeans2.fit(X)
# Getting the cluster labels
labels2 = kmeans2.predict(X)
# Centroid values
centroids = kmeans2.cluster_centers_
f, (ax1,ax2) = plt.subplots(nrows=1, ncols=2, figsize=(10, 5), sharey=True)
ax1.scatter(CompactSFR['lgm_tot_p50'],CompactSFR['sSFR'],c=labels2);
X2 = kmeans2.transform(X)
ax1.set_title("Kmeans 2 clusters", fontsize=15)
ax1.set_xlabel('$\log_{10}(M)$',fontsize=10) ;
ax1.set_ylabel('sSFR',fontsize=10) ;
f.subplots_adjust(hspace=0)
但我得到的分类是:
这是行不通的。你知道吗
此外,我想要的不是简单的分类,而是分离线的方程(这显然与线性回归非常不同)。你知道吗
我想避免发展贝叶斯模型的最大可能性,如果有的东西已经存在。你知道吗
你可以找到一个小样本(959点)here。你知道吗
注意:this question与我的情况不符。你知道吗
下面的代码将使用由两个分量组成的高斯混合模型来实现这一点,并生成这个结果。
首先,从文件中读取数据并删除异常值:
然后拟合高斯混合模型:
要获得绘图:
相关问题 更多 >
编程相关推荐