EarlyStopping

Defined in fynance.models.training

class EarlyStopping(patience=5, min_delta=0., mode='max')[source]

Bases: object

Patience-based early stopping on a monitored metric.

Call step with the validation metric each epoch; it returns True once the metric has failed to improve for patience steps.

Parameters:
patienceint, optional

Number of non-improving steps to tolerate. Default 5.

min_deltafloat, optional

Minimum change counted as an improvement. Default 0.

mode{‘max’, ‘min’}, optional

Whether the metric should be maximized (e.g. Sharpe) or minimized (e.g. loss). Default ‘max’.

Attributes:
bestfloat or None

Best metric seen so far.

stopbool

Whether stopping has been triggered.

step(metric)[source]

Update with a new metric value; return True if training should stop.