lightgbm_callbacks.sklearn package
- class lightgbm_callbacks.sklearn.EstimatorWrapperBase(estimator: TEstimator)[source]
Bases:
BaseEstimator,RegressorMixin,Generic[TEstimator]A base class for estimator wrappers that delegates all attributes to the wrapped estimator.
- set_score_request(*, sample_weight: bool | None | str = '$UNCHANGED$') EstimatorWrapperBase
Request metadata passed to the
scoremethod.Note that this method is only relevant if
enable_metadata_routing=True(seesklearn.set_config()). Please see User Guide on how the routing mechanism works.The options for each parameter are:
True: metadata is requested, and passed toscoreif provided. The request is ignored if metadata is not provided.False: metadata is not requested and the meta-estimator will not pass it toscore.None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.New in version 1.3.
Note
This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a
Pipeline. Otherwise it has no effect.- Parameters:
sample_weight (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for
sample_weightparameter inscore.- Returns:
self – The updated object.
- Return type:
object
- class lightgbm_callbacks.sklearn.LGBMDartEarlyStoppingEstimator(estimator: LGBMModel, *, early_stopping_factory: Callable[[int, bool, bool, float | list[float]], Callable[[CallbackEnv], None]] | Callable[[int, bool, bool], Callable[[CallbackEnv], None]] = <class 'lightgbm_callbacks._early_stopping_callback.DartEarlyStoppingCallback'>, stopping_rounds: int | None = None, first_metric_only: bool = False, verbose: bool = False, min_delta: float | None = None, eval_metric: str | Callable[[NDArray, NDArray], tuple[str, float, bool]] | None = None, test_size: float | int | None = None, train_size: float | int | None = None, random_state: int = 0, shuffle: bool = True, stratify: bool = False, split_enabled: bool = True, dart_early_stopping_method: Literal['save', 'refit', 'none'] = 'save', metric_idx: int = -1, tqdm_cls: Literal['auto', 'autonotebook', 'std', 'notebook', 'asyncio', 'keras', 'dask', 'tk', 'gui', 'rich', 'contrib.slack', 'contrib.discord', 'contrib.telegram', 'contrib.bells'] | type[tqdm.std.tqdm] | None = None, tqdm_kwargs: dict[str, Any] | None = None, **kwargs: Any)[source]
Bases:
LGBMEarlyStoppingEstimatorLightGBM wrapper that does early stopping with sklearn.train_test_split and uses
LGBMDartEarlyStoppingSimpleWrapperto support early stopping in dart mode.- set_score_request(*, sample_weight: bool | None | str = '$UNCHANGED$') LGBMDartEarlyStoppingEstimator
Request metadata passed to the
scoremethod.Note that this method is only relevant if
enable_metadata_routing=True(seesklearn.set_config()). Please see User Guide on how the routing mechanism works.The options for each parameter are:
True: metadata is requested, and passed toscoreif provided. The request is ignored if metadata is not provided.False: metadata is not requested and the meta-estimator will not pass it toscore.None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.New in version 1.3.
Note
This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a
Pipeline. Otherwise it has no effect.- Parameters:
sample_weight (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for
sample_weightparameter inscore.- Returns:
self – The updated object.
- Return type:
object
- class lightgbm_callbacks.sklearn.LGBMDartEarlyStoppingSimpleWrapper(estimator: LGBMModel, *, method: Literal['save', 'refit', 'none'] = 'save', metric_idx: int = -1)[source]
Bases:
EstimatorWrapperBase[LGBMModel]A simple wrapper for dart LGBMModel that returns the best model after early stopping.
- set_score_request(*, sample_weight: bool | None | str = '$UNCHANGED$') LGBMDartEarlyStoppingSimpleWrapper
Request metadata passed to the
scoremethod.Note that this method is only relevant if
enable_metadata_routing=True(seesklearn.set_config()). Please see User Guide on how the routing mechanism works.The options for each parameter are:
True: metadata is requested, and passed toscoreif provided. The request is ignored if metadata is not provided.False: metadata is not requested and the meta-estimator will not pass it toscore.None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.New in version 1.3.
Note
This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a
Pipeline. Otherwise it has no effect.- Parameters:
sample_weight (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for
sample_weightparameter inscore.- Returns:
self – The updated object.
- Return type:
object
- class lightgbm_callbacks.sklearn.LGBMEarlyStoppingEstimator(estimator: LGBMModel, *, early_stopping_factory: Callable[[int, bool, bool, float | list[float]], Callable[[CallbackEnv], None]] | Callable[[int, bool, bool], Callable[[CallbackEnv], None]] = <class 'lightgbm_callbacks._early_stopping_callback.DartEarlyStoppingCallback'>, stopping_rounds: int | None = None, first_metric_only: bool = False, verbose: bool = False, min_delta: float | None = None, eval_metric: str | Callable[[NDArray, NDArray], tuple[str, float, bool]] | None = None, test_size: float | int | None = None, train_size: float | int | None = None, random_state: int = 0, shuffle: bool = True, stratify: bool = False, split_enabled: bool = True, tqdm_cls: Literal['auto', 'autonotebook', 'std', 'notebook', 'asyncio', 'keras', 'dask', 'tk', 'gui', 'rich', 'contrib.slack', 'contrib.discord', 'contrib.telegram', 'contrib.bells'] | type[tqdm.std.tqdm] | None = None, tqdm_kwargs: dict[str, Any] | None = None, **kwargs: Any)[source]
Bases:
EstimatorWrapperBase[LGBMModel]LightGBM wrapper that does early stopping with sklearn.train_test_split.
- set_score_request(*, sample_weight: bool | None | str = '$UNCHANGED$') LGBMEarlyStoppingEstimator
Request metadata passed to the
scoremethod.Note that this method is only relevant if
enable_metadata_routing=True(seesklearn.set_config()). Please see User Guide on how the routing mechanism works.The options for each parameter are:
True: metadata is requested, and passed toscoreif provided. The request is ignored if metadata is not provided.False: metadata is not requested and the meta-estimator will not pass it toscore.None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.New in version 1.3.
Note
This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a
Pipeline. Otherwise it has no effect.- Parameters:
sample_weight (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for
sample_weightparameter inscore.- Returns:
self – The updated object.
- Return type:
object