scikit-learn中的混合模型代码适用于单个数据点的列表,但如果您有直方图呢?也就是说,我对每个体素都有一个密度值,并且我希望混合模型近似它。这个是可能的吗?我认为一种解决方案是从这个直方图中抽样值,但这不是必要的。
发布于 2014-06-24 17:19:19
Scikit-learn具有广泛的核密度估计实用程序和算法,其具体中心是从直方图之类的东西推断分布。有关示例,请参阅文档here。如果您对数据的分布没有任何期望,那么KDE可能是一种更通用的方法。
发布于 2015-05-12 00:26:20
对于2D直方图Z
(体素的2D数组)
import numpy as np
# create the co-ordinate values
X, Y = np.mgrid[0:Z.shape[0], 0:Z.shape[1]]
# artificially create a list of points from your histogram
data_points = []
for x, y, z in zip(X.ravel(), Y.ravel(), Z.ravel()):
# add the data point / voxel (x, y) as many times as it occurs
# in the histogram
for iz in z:
data_points.append((x, y))
# now fit your GMM
from sklearn.mixture import GMM
gmm = GMM()
gmm.fit(data_points)
然而,正如@Kyle Kastner指出的那样,有更好的方法来实现这一点。你能在原始数据入库之前得到它吗?
https://stackoverflow.com/questions/19554581
复制相似问题