Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- mixture = sklearn.mixture.GaussianMixture(n_components=1, covariance_type='full').fit(my_array)
- covariances = mixture.covariances_ # shape = (1, 22, 22) where 1 is the 1 component I fit and 22x22 is the covariance matrix
- means = mixture_component.means_ # shape = (1, 22), 22 means; one for each feautre
- dependent_data = features[:, 0:2] #shape = (10000, 2)
- conditional_data = features[:, 2:] #shape = (10000, 20)
- mu_a = means[:, 0:2] # Mu of the dependent variables
- mu_b = means[:, 2:] # Mu of the independent variables
- cov_aa = covariances[0, 0:2, 0:2] # Cov of the dependent vars
- cov_bb = covariances[0, 2:, 2:] # Cov of independent vars
- cov_ab = covariances[0, 0:2, 2:]
- cov_ba = covariances[0, 2:, 0:2]
- A = (conditional_data.transpose() - mu_b.transpose())
- B = cov_ab.dot(np.linalg.inv(cov_bb))
- conditional_mu = mu_a + B.dot(A).transpose()
- conditional_cov = cov_aa - cov_ab.dot(np.linalg.inv(cov_bb)).dot(cov_ba)
- conditional_mu.shape
- (10000, 2)
- conditional_cov.shape
- (2,2)
Add Comment
Please, Sign In to add comment