neuraxle.metaopt.callbacks

Neuraxle’s training callbacks classes.

Training callback classes.

Functions

BestModelCheckpoint()

Saves the pipeline model in a folder named “best” when the a new best validation score is reached.

Classes

BaseCallback

Base class for a training callback.

CallbackList(callbacks)

Callback list that be executed.

EarlyStoppingCallback(…[, metric_name])

Perform early stopping when there is multiple epochs in a row that didn’t improve the performance of the model.

IfBestScore(wrapped_callback)

Meta callback that only execute when the trial is a new best score.

IfLastStep(wrapped_callback)

Meta callback that only execute when the training is finished or fitted, or when it is the last epoch.

MetaCallback(wrapped_callback)

Meta callback wraps another callback.

MetricCallback(name, metric_function, …[, …])

Callback that calculates metric results.

ScoringCallback(metric_function[, name])

Metric Callback that calculates metric results for the main scoring metric.

StepSaverCallback(label)

Callback that saves the trial model.

class neuraxle.metaopt.callbacks.BaseCallback[source]

Base class for a training callback. Callbacks are called after each epoch inside the fit function of the Trainer.

_abc_cache = <_weakrefset.WeakSet object>[source]
_abc_negative_cache = <_weakrefset.WeakSet object>[source]
_abc_negative_cache_version = 60
_abc_registry = <_weakrefset.WeakSet object>[source]
call(trial_split: neuraxle.metaopt.trial.TrialSplit, epoch_number: int, total_epochs: int, input_train: neuraxle.data_container.DataContainer, pred_train: neuraxle.data_container.DataContainer, input_val: neuraxle.data_container.DataContainer, pred_val: neuraxle.data_container.DataContainer, context: neuraxle.base.ExecutionContext, is_finished_and_fitted: bool)[source]
neuraxle.metaopt.callbacks.BestModelCheckpoint()[source]

Saves the pipeline model in a folder named “best” when the a new best validation score is reached. It is important to note that when refit=True, an AutoML loop will overwrite the best model after refitting.

class neuraxle.metaopt.callbacks.CallbackList(callbacks)[source]

Callback list that be executed.

_abc_cache = <_weakrefset.WeakSet object>[source]
_abc_negative_cache = <_weakrefset.WeakSet object>[source]
_abc_negative_cache_version = 60
_abc_registry = <_weakrefset.WeakSet object>[source]
call(trial_split: neuraxle.metaopt.trial.TrialSplit, epoch_number: int, total_epochs: int, input_train: neuraxle.data_container.DataContainer, pred_train: neuraxle.data_container.DataContainer, input_val: neuraxle.data_container.DataContainer, pred_val: neuraxle.data_container.DataContainer, context: neuraxle.base.ExecutionContext, is_finished_and_fitted: bool)[source]
class neuraxle.metaopt.callbacks.EarlyStoppingCallback(max_epochs_without_improvement, metric_name=None)[source]

Perform early stopping when there is multiple epochs in a row that didn’t improve the performance of the model.

_abc_cache = <_weakrefset.WeakSet object>[source]
_abc_negative_cache = <_weakrefset.WeakSet object>[source]
_abc_negative_cache_version = 60
_abc_registry = <_weakrefset.WeakSet object>[source]
call(trial_split: neuraxle.metaopt.trial.TrialSplit, epoch_number: int, total_epochs: int, input_train: neuraxle.data_container.DataContainer, pred_train: neuraxle.data_container.DataContainer, input_val: neuraxle.data_container.DataContainer, pred_val: neuraxle.data_container.DataContainer, context: neuraxle.base.ExecutionContext, is_finished_and_fitted: bool)[source]
class neuraxle.metaopt.callbacks.IfBestScore(wrapped_callback: neuraxle.metaopt.callbacks.BaseCallback)[source]

Meta callback that only execute when the trial is a new best score.

_abc_cache = <_weakrefset.WeakSet object>[source]
_abc_negative_cache = <_weakrefset.WeakSet object>[source]
_abc_negative_cache_version = 60
_abc_registry = <_weakrefset.WeakSet object>[source]
call(trial_split: neuraxle.metaopt.trial.TrialSplit, epoch_number: int, total_epochs: int, input_train: neuraxle.data_container.DataContainer, pred_train: neuraxle.data_container.DataContainer, input_val: neuraxle.data_container.DataContainer, pred_val: neuraxle.data_container.DataContainer, context: neuraxle.base.ExecutionContext, is_finished_and_fitted: bool)[source]
class neuraxle.metaopt.callbacks.IfLastStep(wrapped_callback: neuraxle.metaopt.callbacks.BaseCallback)[source]

Meta callback that only execute when the training is finished or fitted, or when it is the last epoch.

_abc_cache = <_weakrefset.WeakSet object>[source]
_abc_negative_cache = <_weakrefset.WeakSet object>[source]
_abc_negative_cache_version = 60
_abc_registry = <_weakrefset.WeakSet object>[source]
call(trial_split: neuraxle.metaopt.trial.TrialSplit, epoch_number: int, total_epochs: int, input_train: neuraxle.data_container.DataContainer, pred_train: neuraxle.data_container.DataContainer, input_val: neuraxle.data_container.DataContainer, pred_val: neuraxle.data_container.DataContainer, context: neuraxle.base.ExecutionContext, is_finished_and_fitted: bool)[source]
class neuraxle.metaopt.callbacks.MetaCallback(wrapped_callback: neuraxle.metaopt.callbacks.BaseCallback)[source]

Meta callback wraps another callback. It can be useful to test conditions before executing certain callbacks.

_abc_cache = <_weakrefset.WeakSet object>[source]
_abc_negative_cache = <_weakrefset.WeakSet object>[source]
_abc_negative_cache_version = 60
_abc_registry = <_weakrefset.WeakSet object>[source]
call(trial_split: neuraxle.metaopt.trial.TrialSplit, epoch_number: int, total_epochs: int, input_train: neuraxle.data_container.DataContainer, pred_train: neuraxle.data_container.DataContainer, input_val: neuraxle.data_container.DataContainer, pred_val: neuraxle.data_container.DataContainer, context: neuraxle.base.ExecutionContext, is_finished_and_fitted: bool)[source]
class neuraxle.metaopt.callbacks.MetricCallback(name: str, metric_function: Callable, higher_score_is_better: bool, log_metrics=True, pass_context_to_metric_function: bool = False)[source]

Callback that calculates metric results. Adds the results into the trial repository.

_abc_cache = <_weakrefset.WeakSet object>[source]
_abc_negative_cache = <_weakrefset.WeakSet object>[source]
_abc_negative_cache_version = 60
_abc_registry = <_weakrefset.WeakSet object>[source]
call(trial_split: neuraxle.metaopt.trial.TrialSplit, epoch_number: int, total_epochs: int, input_train: neuraxle.data_container.DataContainer, pred_train: neuraxle.data_container.DataContainer, input_val: neuraxle.data_container.DataContainer, pred_val: neuraxle.data_container.DataContainer, context: neuraxle.base.ExecutionContext, is_finished_and_fitted: bool)[source]
class neuraxle.metaopt.callbacks.ScoringCallback(metric_function: Callable, name='main', higher_score_is_better: bool = True, log_metrics: bool = True, pass_context_to_metric_function: bool = False)[source]

Metric Callback that calculates metric results for the main scoring metric. Adds the results into the trial repository.

_abc_cache = <_weakrefset.WeakSet object>[source]
_abc_negative_cache = <_weakrefset.WeakSet object>[source]
_abc_negative_cache_version = 60
_abc_registry = <_weakrefset.WeakSet object>[source]
class neuraxle.metaopt.callbacks.StepSaverCallback(label)[source]

Callback that saves the trial model.

_abc_cache = <_weakrefset.WeakSet object>[source]
_abc_negative_cache = <_weakrefset.WeakSet object>[source]
_abc_negative_cache_version = 60
_abc_registry = <_weakrefset.WeakSet object>[source]
call(trial_split: neuraxle.metaopt.trial.TrialSplit, epoch_number: int, total_epochs: int, input_train: neuraxle.data_container.DataContainer, pred_train: neuraxle.data_container.DataContainer, input_val: neuraxle.data_container.DataContainer, pred_val: neuraxle.data_container.DataContainer, context: neuraxle.base.ExecutionContext, is_finished_and_fitted: bool)[source]