Skip to content

LightGBM Adapter API

This section documents the LightGBM adapter used to integrate lightgbm.LGBMRegressor into the eb-adapters package.

All content below is generated automatically from NumPy-style docstrings in the source code.

LightGBM Adapter Module

eb_adapters.lightgbm

LightGBMRegressorAdapter

Bases: BaseAdapter

Adapter for lightgbm.LGBMRegressor.

This adapter exposes a scikit-learn-like API and stores initialization parameters so the instance can be reconstructed by cloning utilities (for example, an internal clone_model() helper or sklearn.base.clone).

Parameters:

Name Type Description Default
**lgbm_params Any

Keyword arguments forwarded to lightgbm.LGBMRegressor.

{}
Notes
  • X and y are treated as standard tabular regression inputs.
  • If provided, sample_weight is passed through to LightGBM training.
  • All initialization parameters are stored in self.lgbm_params.

Examples:

>>> model = LightGBMRegressorAdapter(
...     n_estimators=200,
...     learning_rate=0.05,
...     max_depth=-1,
... )
>>> # X, y are numpy arrays (or array-like)
>>> # model.fit(X, y).predict(X)

fit(X, y, sample_weight=None)

Fit the underlying lightgbm.LGBMRegressor.

Parameters:

Name Type Description Default
X ndarray

Feature matrix of shape (n_samples, n_features).

required
y ndarray

Target vector of shape (n_samples,).

required
sample_weight ndarray | None

Optional per-sample weights of shape (n_samples,). If provided, this is forwarded to LightGBM training.

None

Returns:

Type Description
LightGBMRegressorAdapter

The fitted adapter (self), allowing method chaining.

Raises:

Type Description
RuntimeError

If LightGBM is not available or the internal model is not initialized.

predict(X)

Predict using the fitted LightGBM model.

Parameters:

Name Type Description Default
X ndarray

Feature matrix of shape (n_samples, n_features).

required

Returns:

Type Description
ndarray

Predicted values of shape (n_samples,).

Raises:

Type Description
RuntimeError

If the adapter has not been fit yet.

get_params(deep=True)

Return initialization parameters for cloning utilities.

Parameters:

Name Type Description Default
deep bool

Included for scikit-learn compatibility. This adapter does not expose nested estimators, so the value does not change the output.

True

Returns:

Type Description
dict[str, Any]

A shallow copy of the stored initialization parameters.

set_params(**params)

Update parameters and rebuild the underlying LightGBM model.

Parameters:

Name Type Description Default
**params Any

Keyword parameters to merge into the stored initialization parameters.

{}

Returns:

Type Description
LightGBMRegressorAdapter

The updated adapter instance (self).

Notes

This method updates self.lgbm_params and then re-instantiates lightgbm.LGBMRegressor using the merged parameter set.