FitCallback#

class sklearn.callback.FitCallback[source]#

Base class for the callbacks evaluated during the fit of an estimator.

get_metadata_routing()[source]#

Get metadata routing of this object.

Please check User Guide on how the routing mechanism works.

Returns:
routingMetadataRequest

A MetadataRequest encapsulating routing information.

on_fit_task_begin(estimator, context, *, X=None, y=None, fitted_estimator=None)[source]#

Method called at the beginning of each fit task of the estimator.

Parameters:
estimatorestimator instance

The estimator calling this callback hook.

contextsklearn.callback.CallbackContext instance

Context of the corresponding task.

Xarray-like

The training data at this task.

yarray-like

The training target values at this task.

fitted_estimatorestimator instance

A new instance of the estimator that is ready to predict, transform, etc … as if fit had stopped at the beginning of this task.

on_fit_task_end(estimator, context, *, X=None, y=None, fitted_estimator=None)[source]#

Method called at the end of each fit task of the estimator.

Parameters:
estimatorestimator instance

The estimator calling this callback hook.

contextsklearn.callback.CallbackContext instance

Context of the corresponding task.

Xarray-like

The training data at this task.

yarray-like

The training target values at this task.

fitted_estimatorestimator instance

A new instance of the estimator that is ready to predict, transform, etc … as if fit had stopped at the end of this task.

Returns:
stopbool

Whether or not to stop the current level of iterations at this task.

setup(estimator, context)[source]#

Method called at the beginning of the fit method of the estimator.

For auto-propagated callbacks, this method is called only once, before running the fit method of the outermost estimator.

Parameters:
estimatorestimator instance

The estimator calling this callback hook.

contextsklearn.callback.CallbackContext instance

Context of the corresponding task. This is usually the root context of the estimator but it can be an intermediate context if the estimator is a sub-estimator of a meta-estimator.

teardown(estimator, context)[source]#

Method called after finishing the fit method of the estimator.

For auto-propagated callbacks, this method is called only once, after finishing the fit method of the outermost estimator.

Parameters:
estimatorestimator instance

The estimator calling this callback hook.

contextsklearn.callback.CallbackContext instance

Context of the corresponding task. This is usually the root context of the estimator but it can be an intermediate context if the estimator is a sub-estimator of a meta-estimator.