Mf_track (models.mf_track)

class nimfa.models.mf_track.Mf_track

Base class for tracking MF fitted model across multiple runs of the factorizations or tracking the residuals error across iterations of single/multiple runs.

The purpose of this class is to store matrix factors from multiple runs of the algorithm which can then be used for performing quality and performance measures. Because of additional space consumption for storing multiple matrix factors, tracking is used only if explicitly specified by user through runtime option. In summary, when tracking factors, the following is retained from each run:

  1. fitted factorization model depending on the factorization method;
  2. final value of objective function;
  3. performed number of iterations.

Instead of tracking fitted factorization model, callback function can be set, which will be called after each factorization run. For more details see mf_run.

The purpose of this class is to store residuals across iterations which can then be used for plotting the trajectory of the residuals track or estimating proper number of iterations.

get_error(run=0)

Return residuals track from one run of the factorization.

Parameters:run (int) – Specify the run of which error track is desired. By default run is 1.
get_factor(run=0)

Return matrix factorization factors from run :param:`run`.

Parameters:run (int) – Saved factorization factors (and method specific model data) of run‘th run are returned.
track_error(run, residuals)

Add residuals error after one iteration.

Parameters:
  • run (int) – Specify the run to which residuals belongs. Error tracking can be also used if multiple runs are enabled.
  • residuals (float) – Residuals between the target matrix and its MF estimate.
track_factor(run, **track_model)

Add matrix factorization factors (and method specific model data) after one factorization run.

Parameters:
  • run (‘int’) – Specify the run to which track_model belongs.
  • track_model (algorithm specific) – Matrix factorization factors.
class nimfa.models.mf_track.t_model(td)

Tracking factors model.

Fork me on GitHub