- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用 GMM 来分割/聚类 800x800 像素和 4 个波段的高光谱图像数据。
我拍了一张照片并应用 GMM 来聚类像素。
现在,在我目前的情况下,我很容易手动确定图像中有多少个组件。 (草、水、岩石...等)
我已对 n_components=3..8 中的数据手动运行 GMM,并确定 5 个分量可能是对现实进行建模的最佳 n_components。
在未来的应用程序中,我需要能够自动识别我应该在 GMM 中使用的 n_components,因为手动确定是不可能的。
因此,我决定使用 BIC 作为成本函数来确定模型中使用的正确 n_components。
我在测试数据上运行了 BIC,手动确定 n_components=5 是最佳模型现实,发现 BIC 严重过度拟合我的数据。
这建议我使用尽可能多的组件。
newdata=img_data.reshape(800*800,4)
n_components = np.arange(1, 15)
BIC = np.zeros(n_components.shape)
for i, n in enumerate(n_components):
gmm = GaussianMixture(n_components=n,
covariance_type='tied')
gmm.fit(newdata)
BIC[i] = gmm.bic(newdata)
plt.plot(BIC)
现在理想情况下,我希望看到我的 BIC 分数最小化为 5,但正如您在上面看到的,它看起来随着 n_components 的增加而不断下降。
有人知道这里会发生什么吗?也许我需要在使用 BIC 之前以某种方式平滑数据以减少噪音?还是我使用BIC功能不当?
最佳答案
因此,经过一番谷歌搜索后,我决定对我的数组应用一个简单的高斯平滑滤波器,它似乎在我的 BIC 分数列表中产生了一个局部最小值,这就是我期望的 n_components 。我编写了一个小脚本来挑选第一个本地最小值并将其用作我的 gmm 模型的参数。
newdata=img_data.reshape(800*800,4)
#Apply a Gaussian smoothing filter over a pixel neighborhood
newdata=sy.ndimage.filters.gaussian_filter(newdata,(1.5,1.5))
#Create the vector of n_components you wish to test using the BIC alogrithm
n_components = np.arange(1, 10)
#Create an empty vector in which to store BIC scores
BIC = np.zeros(n_components.shape)
for i, n in enumerate(n_components):
#Fit gmm to data for each value in n_components vector
gmm = GaussianMixture(n_components=n,
covariance_type='tied')
gmm.fit(newdata)
#Store BIC scores in a list
BIC[i] = gmm.bic(newdata)
#Plot resulting BIC list (Scores(n_components))
plt.plot(BIC)
plt.show()
关于python - BIC 使用 scikit-learn 中的 GaussianMixture 过度拟合图像分割模型中的组件数量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44373504/
我正在使用 GaussianMixture 进行剪影分析。我试图修改在 scikit 网站上编写的类似代码,但出现了奇怪的错误:- --> 82 centers = clusterer.cluster
我有一个混合模型: gm = mixture.GaussianMixture( n_components=3, covariance_t
我想使用 sklearn.mixture.GaussianMixture 来存储高斯混合模型,以便以后可以使用它来生成样本或使用 score_samples 方法在样本点生成值。这是一个示例,其中分量
我想使用 scikit-learn 的 GaussianMixture 函数,我必须执行模型选择。 我想通过使用 GridSearchCV 来做到这一点,我想使用 BIC 和 AIC 进行选择。 这两
我已经标记了二维数据。集合中有 4 个标签,我知道每个点与其标签的对应关系。我想,给定一个新的任意数据点,找出它具有 4 个标签中的每一个的概率。它必须属于一个且仅属于一个标签,因此概率之和应为 1。
我正在使用 GMM 来分割/聚类 800x800 像素和 4 个波段的高光谱图像数据。 我拍了一张照片并应用 GMM 来聚类像素。 现在,在我目前的情况下,我很容易手动确定图像中有多少个组件。 (草、
在 scikit-learn 中,GaussianMixture 对象具有实现贝叶斯信息准则的方法 bic(X) 来选择更适合数据的组件。这是一个用法示例: from sklearn import m
我正在尝试使用 GaussianMixture 模型进行图像分割,所以我使用了 2 个组件,协方差矩阵 type="full"并尝试使用 anaconda 附带的 Spyder3.6 运行。这是代码:
我正在使用 pyspark.ml.clustering 库处理 iris 数据集,以便了解 pyspark 的基础知识并为我创建一个聚类模板。 我的spark版本是2.1.1,hadoop版本是2.7
我有一段代码可以为我的数据拟合高斯模型。我从 sklearn 导入了混合物。但是,即使我使用 mixture.GaussianMixture,我也会收到错误消息:AttributeError: 'mo
我是一名优秀的程序员,十分优秀!