Skip to content

callbacks

Callbacks for training.

Callback #

Represents a callback for the explainable model.

EarlyStopping #

Initialize the EarlyStopping callback.

Parameters:

Name Type Description Default
monitoring_metric

The metric name to use for early stopping.

required
reset_after_pruning

If True, reset the best metrics after pruning. Else keep the best model regardless of the pruning.

required
min_delta

Minimum delta between two monitoring values to consider an improvement.

required
patience

Number of epochs to wait with no improvement of the monitoring value.

required
mode

Whether to "maximize" or "minimize" the provided metric.

required
num_pruning_criteria

Minimal number of pruning steps performed required.

required
num_leaf_criteria

Minimal number of remaining leaves required.

required

monitoring_metric: str #

reset_after_pruning: bool = True #

patience: int = 3 #

min_delta: float = 0.0 #

mode: str = 'min' #

num_pruning_criteria: int | None = None #

num_leaf_criteria: int | None = None #

LrScheduler #

Initialize a scheduler object to encapsulate different torch schedulers.

Parameters:

Name Type Description Default
pre_scheduler

Based torch lr scheduler or no scheduler to be instantiated.

required
step_method

"epoch" or "batch".

required
monitoring_metric

Optional monitoring metric required for the step method, default None.

required

pre_scheduler: partial[LRScheduler | ReduceLROnPlateau] #

step_method: str | None = None #

monitoring_metric: str | None = None #

ModelCheckpoint #

Model checkpoint initialization.

Parameters:

Name Type Description Default
mode

Whether to "maximize" or "minimize" the provided metric.

required
monitoring_metric

Monitoring metric required for the step method, default None.

required
reset_after_pruning

If True, reset the best metrics after pruning. Else keep the best model regardless of the pruning.

required
save_every_epoch

How often to save the model. If None, only save the best checkpoint.

required

mode: str | None #

monitoring_metric: str #

reset_after_pruning: bool #

save_every_epoch: int | None = 1 #