0

I trained GMM model using 2 classes. And I also tested some sample data from trained GMM model. Finally, I want to get a probability for each class's gmm.

I used sklearn GaussianMixture function named predict_proba. But it shows in array. How can I get it in percentage?

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()

shape of "a" is (1189L,2L) and data shows like this.

 [[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]]
sanghoon
  • 19
  • 3
  • Did you train two GMMs or a single GMM with two compoments? Also, what exactly is wrong with the output, wouldn't `a * 100.0` solve the problem? – dedObed Jun 28 '19 at 11:21

1 Answers1

0

you are getting a correct response row of a to denote the data point and probability associate for class 1 and class 2 is in column 1 and column 2.

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

Akash Kumar
  • 182
  • 2
  • 12