GaussianMixture initialization using component parameters - sklearn

前端 未结 3 1446
刺人心
刺人心 2021-02-10 01:16

I want to use sklearn.mixture.GaussianMixture to store a gaussian mixture model so that I can later use it to generate samples or a value at a sample point using score_sam

3条回答
  •  伪装坚强ぢ
    2021-02-10 01:58

    You rock, J.P.Petersen! After seeing your answer I compared the change introduced by using fit method. It seems the initial instantiation does not create all the attributes of gmix. Specifically it is missing the following attributes,

    covariances_
    means_
    weights_
    converged_
    lower_bound_
    n_iter_
    precisions_
    precisions_cholesky_
    

    The first three are introduced when the given inputs are assigned. Among the rest, for my application the only attribute that I need is precisions_cholesky_ which is cholesky decomposition of the inverse covarinace matrices. As a minimum requirement I added it as follow,

    gmix.precisions_cholesky_ = np.linalg.cholesky(np.linalg.inv(sigma)).transpose((0, 2, 1))
    

提交回复
热议问题