stnmf.callbacks.stopping_criterion

stnmf.callbacks.stopping_criterion(self, i, itor, callback_data, interval=100, delta=1e-06)

Callback function to implement a custom stopping criterion based on relative reconstruction improvement

Parameters:
  • interval (int, optional) – Evaluate stopping criterion every interval iterations

  • delta (float, optional) – Fraction of first-iteration improvement. When the difference to the previous reconstruction error falls below, terminate the factorization. Default is 1e-6

Notes

This callback function is not specific to stnmf.STNMF and can be used in conjunction with other snmt.mf classes.

Warning

The reconstruction residual is not a suitable metric reconstruction quality in the scope of stnmf.STNMF, due to the sparsity involved!

Examples

>>> from stnmf import STNMF
>>> from stnmf.callbacks import stoppping_criterion
>>> stnmf = STNMF(ste, callback=stoppping_criterion,
...               callback_kwargs=dict(interval=100))