I would like to change a class sklearn.mixture.GaussianMixture
to compute GMM with fixed means. In this github repository the function is stored, I assume it would be enough to change that means_
will not be computed in _m_step
function within the class sklearn.mixture.GaussianMixture
, but instead the values provided as initial values for means, i.e. mean_init
parameter of the class would be used as fixed means. How to achieve this? I have tried changing it by heart by copy-paste the class and changing the part inside the function, but I can not overcome that there are dependencies which I can not load... Is it possible to change it from outside somehow?
So this is what I have tried, but I am not able to make it running:
import sklearn
def new_m_step(self, X, log_resp):
sklearn.mixture.GaussianMixture._m_step(self, X, log_resp)
self.means_ = self.means_init
my_gmm = sklearn.mixture.gaussian_mixture.GaussianMixture()
#my_gmm._m_step = types.MethodType(new_m_step, my_gmm) # alternative which has the same error
my_gmm._m_step = new_m_step.__get__(my_gmm, sklearn.mixture.gaussian_mixture.GaussianMixture)
and I get this error:
TypeError: 'GaussianMixture' object is not callable