python - 我如何获得每个 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]]
解决方案
您将获得正确的响应行 a 来表示第 1 类和第 2 类的数据点和概率关联在第 1 列和第 2 列中。
https://scikit-learn.org/stable/modules/generated/sklearn.mixture.GaussianMixture.html
推荐阅读
- c# - 从 varchar Unix Timestamp 上的实体框架 DbSet 检索记录的最快方法
- unity3d - 单位像素
- mysql - 如何在无法登录 mysql 的情况下恢复默认 [mysql] 系统数据库?
- swift - 如何在 SwiftUI 中将图像转换为 Base64?
- css - 递归定位和修改特定类型的第一个元素的 css
- python - Python 将变量值重置为 _init_ 中的值
- mongodb - 如何安全地停止 mongodump?
- python - 输入错误:文件扩展名“.log”没有脚本引擎
- c++ - 基于索引的C ++字符数组元素不进行比较
- php - 动态传递产品 ID 作为重力表单上的主要产品字段(产品附加)