Guest User

Untitled

a guest
Jan 20th, 2018
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. mixture = sklearn.mixture.GaussianMixture(n_components=1, covariance_type='full').fit(my_array)
  2.  
  3. covariances = mixture.covariances_ # shape = (1, 22, 22) where 1 is the 1 component I fit and 22x22 is the covariance matrix
  4. means = mixture_component.means_ # shape = (1, 22), 22 means; one for each feautre
  5. dependent_data = features[:, 0:2] #shape = (10000, 2)
  6. conditional_data = features[:, 2:] #shape = (10000, 20)
  7. mu_a = means[:, 0:2] # Mu of the dependent variables
  8. mu_b = means[:, 2:] # Mu of the independent variables
  9. cov_aa = covariances[0, 0:2, 0:2] # Cov of the dependent vars
  10. cov_bb = covariances[0, 2:, 2:] # Cov of independent vars
  11. cov_ab = covariances[0, 0:2, 2:]
  12. cov_ba = covariances[0, 2:, 0:2]
  13. A = (conditional_data.transpose() - mu_b.transpose())
  14. B = cov_ab.dot(np.linalg.inv(cov_bb))
  15. conditional_mu = mu_a + B.dot(A).transpose()
  16. conditional_cov = cov_aa - cov_ab.dot(np.linalg.inv(cov_bb)).dot(cov_ba)
  17.  
  18. conditional_mu.shape
  19. (10000, 2)
  20. conditional_cov.shape
  21. (2,2)
Add Comment
Please, Sign In to add comment