delu.ProgressTracker#

class delu.ProgressTracker(patience, min_delta=0.0)[source]#

[DEPRECATED | Instead, use delu.EarlyStopping. For tracking the best metric value, currently, no alternatives are provided.] Helps with early stopping and tracks the best metric value.

For ProgressTracker, the greater score is the better score. At any moment the tracker is in one of the following states:

  • success: the last update increased the best score

  • fail: last n > patience updates did not improve the best score

  • neutral: if neither success nor fail

Tutorial

progress = delu.ProgressTracker(2)
progress.update(-999999999)
assert progress.success  # the first update always updates the best score

progress.update(123)
assert progress.success
assert progress.best_score == 123

progress.update(0)
assert not progress.success and not progress.fail

progress.update(123)
assert not progress.success and not progress.fail
progress.update(123)
# patience is 2 and the best score is not updated for more than 2 steps
assert progress.fail
assert progress.best_score == 123  # fail doesn't affect the best score
progress.update(123)
assert progress.fail  # still no improvements

progress.forget_bad_updates()
assert not progress.fail and not progress.success
assert progress.best_score == 123
progress.update(0)
assert not progress.fail  # just 1 bad update (the patience is 2)

progress.reset()
assert not progress.fail and not progress.success
assert progress.best_score is None

Attributes

best_score

The best score so far.

fail

Check if the tracker is in the "fail" state.

success

Check if the tracker is in the "success" state.

Methods

__init__

Initialize self.

forget_bad_updates

Reset unsuccessfull update counter and set the status to "neutral".

reset

Reset everything.

update

Submit a new score and update the tracker's state accordingly.

Parameters:
  • patience (int | None) –

  • min_delta (float) –