我使用2类训练了GMM模型。我还测试了训练有素的GMM模型中的一些示例数据。最后,我想获得每个班级GMM的概率。
我使用了名为preadion_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]]
您获得了A的正确响应行,以表示1类和2类的数据点和概率关联,在第1列和第2列中。
。https://scikit-learn.org/stable/modules/generated/sklearn.mixture.gaussianmixture.html