使用sklearn GMM计算概率

使用sklearn GMM计算概率,第1张

概述我想确定数据点属于一组数据的概率.我读到sklearn GMM可以做到这一点.我试过以下…… import numpy as npfrom sklearn.mixture import GMMtraining_data = np.hstack(( np.random.normal(500, 100, 2000).reshape(-1, 1), np.random.normal 我想确定数据点属于一组数据的概率.我读到sklearn GMM可以做到这一点.我试过以下……

import numpy as npfrom sklearn.mixture import GMMtraining_data = np.hstack((    np.random.normal(500,100,2000).reshape(-1,1),np.random.normal(500,))# train the classifIEr and get max scoreg = GMM(n_components=1)g.fit(training_data)scores = g.score(training_data)max_score = np.amax(scores)# create a candIDate data point and calculate the probability# it belongs to the training populationcandIDate_data = np.array([[490,450]])candIDate_score = g.score(candIDate_data)

从这一点开始,我不知道该怎么做.我正在阅读我必须规范化对数概率,以便获得候选数据点属于总体的概率.会是这样的……

candIDate_probability = (np.exp(candIDate_score)/np.exp(max_score)) * 100print candIDate_probability>>> [ 87.81751913]

这个数字似乎并不合理,但我真的离开了我的舒适区,所以我想我会问.谢谢!

解决方法 您使用的candIDate_probability在统计上不正确.
我认为你需要做的是计算样本点只是其中一个单独高斯的成员的概率(来自权重和多变量累积分布函数(CDF))并总结这些概率.最大的问题是我找不到可以计算多变量CDF的好的python包.除非你能找到一个,否则本文将是一个很好的起点 https://upload.wikimedia.org/wikipedia/commons/a/a2/Cumulative_function_n_dimensional_Gaussians_12.2013.pdf 总结

以上是内存溢出为你收集整理的使用sklearn GMM计算概率全部内容,希望文章能够帮你解决使用sklearn GMM计算概率所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/1197197.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-03
下一篇 2022-06-03

发表评论

登录后才能评论

评论列表(0条)

保存