Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Finding conditional Gaussian Mixture Model using scikit-learn.mixture.GMM

I'm using scikit-learn to fit a multivariate Gaussian Mixture Model to some data (which works brilliantly). But I need to be able to get a new GMM conditional on some of the variables, and the scikit toolkit doesn't seem to be able to do that, which surprised me because it seems like a pretty basic thing to want to do.

Wikipedia has a good explanation of what I'm trying to do (for a single Gaussian, not a GMM), and it's just possible I might be able to implement it myself, but my matrix maths isn't great and I can see it taking a long time.

Has somebody already done this? Is there an easy way of doing it with NumPy/SciPy/Scikit-learn?

like image 754
TomG Avatar asked Oct 19 '22 18:10

TomG


1 Answers

Try looking into pypr. From the documentation, here is how you would find a GMM conditioned on one or more of the variables:

# Now we will find the conditional distribution of x given y
(con_cen, con_cov, new_p_k) = gmm.cond_dist(np.array([np.nan, y]), \
    cen_lst, cov_lst, p_k)

As far as i remember, there are examples that come with the package.

like image 90
statBeginner Avatar answered Nov 15 '22 13:11

statBeginner