首页 > 解决方案 > 我如何获得每个 GMM 的概率百分比?

问题描述

我使用 2 个类训练了 GMM 模型。我还测试了一些来自经过训练的 GMM 模型的样本数据。最后,我想得到每个班级的 gmm 的概率。

我使用了名为 predict_proba 的 sklearn GaussianMixture 函数。但它显示在数组中。我怎样才能得到它的百分比?

for i in range(len(models)):
    gmm    = models[i]  #checking with each model one by one
    scores = np.array(gmm.score(vector))
    a=gmm.predict_proba(vector)
    print a.shape
    log_likelihood[i] = scores.sum()

“a”的形状是(1189L,2L),数据显示如下。

 [[6.21130685e-06 9.99993789e-01]
 [1.50996162e-15 1.00000000e+00]
 [4.79883191e-14 1.00000000e+00]
 ...
 [9.03135413e-08 9.99999910e-01]
 [6.83288657e-12 1.00000000e+00]
 [2.66804391e-08 9.99999973e-01]]
[[0.04394473 0.95605527]
 [0.56844297 0.43155703]
 [0.37858995 0.62141005]
 ...
 [0.06809051 0.93190949]
 [0.03412009 0.96587991]
 [0.00584213 0.99415787]]

标签: pythongmm

解决方案


您将获得正确的响应行 a 来表示第 1 类和第 2 类的数据点和概率关联在第 1 列和第 2 列中。

https://scikit-learn.org/stable/modules/generated/sklearn.mixture.GaussianMixture.html


推荐阅读