mrftools.EM module

EM learner class.

class mrftools.EM.EM(inference_type)[source]

Bases: mrftools.Learner.Learner

Objects that perform expectation maximization for learning with latent variables.

e_step(weights)[source]
learn(weights, optimizer=<function ada_grad>, callback=None, opt_args=None)[source]

Fit model parameters by alternating inference of latent variables and learning the best parameters to fit all variables. This method implements the variational expectation-maximization concept.

Parameters:
  • weights – Initial weight vector. Can be used to warm start from a previous solution.
  • optimizer – gradient-based optimization function, as defined in opt.py
  • callback – callback function run during each iteration of the optimizer. The function receives the weights as input. Can be useful for diagnostics, live plotting, storing records, etc.
  • opt_args – optimization arguments. Usually a dictionary of parameter values
Returns:

learned weights

m_step(weights, optimizer=<function ada_grad>, callback=None, opt_args=None)[source]