API Reference

This page provides a detailed reference to the LESS API.

class less.LESSBRegressor(n_subsets: int = 20, n_estimators: int = 100, learning_rate: float = 0.1, local_estimator: str | Callable[[], Any] = 'linear', global_estimator: str | Callable[[], Any] | None = 'xgboost', cluster_method: str | Callable[[...], Any] = 'tree', val_size: float | None = None, kernel_coeff: float | None = 0.1, min_neighbors: int = 10, early_stopping_tolerance: float = 1e-08, random_state: int | RandomState | None = None)

LESSB (Learning with Subset Stacking Boosting) Regressor.

This regressor implements the boosting variant of the LESS algorithm. It iteratively fits stages, where each stage consists of a set of local models that predict the residuals of the previous stage.

Parameters

n_subsetsint, default=20

Number of local subsets to create for training.

n_estimatorsint, default=100

The number of boosting stages to perform.

learning_ratefloat, default=0.1

The learning rate shrinks the contribution of each stage.

local_estimatorstr or callable, default=’linear’

The local estimator for modeling data subsets.

global_estimatorstr or callable or None, default=’xgboost’

The global meta-estimator for combining local model predictions.

cluster_methodstr or callable, default=’tree’

The method for selecting subset centers.

val_sizefloat, optional

The proportion of the dataset to reserve for the global estimator.

kernel_coefffloat or None, default=0.1

The RBF kernel coefficient for distance weighting.

min_neighborsint, default=10

The minimum number of neighbors for each local subset.

early_stopping_tolerancefloat, default=1e-8

Tolerance for early stopping based on residual improvement.

random_stateint or np.random.RandomState, optional

Controls the randomness for reproducibility.

Attributes

n_features_in_int

The number of features seen during fit().

feature_names_in_np.ndarray of shape (n_features_in_,)

Names of features seen during fit().

_local_models_stageslist[list[LocalModel]]

A list containing the lists of local models for each boosting stage.

_global_models_stageslist[Any]

A list containing the global model for each boosting stage.

_base_predictionfloat

The initial base prediction, typically the mean of the target values.

fit(X: ndarray, y: ndarray, sample_weight: ndarray | None = None) LESSBRegressor

Fit the LESSB regressor using boosting.

Parameters

Xnp.ndarray of shape (n_samples, n_features)

The training input samples.

ynp.ndarray of shape (n_samples,)

The target values.

sample_weightnp.ndarray of shape (n_samples,), optional

Sample weights. Not currently used.

Returns

LESSBRegressor

The fitted regressor.

predict(X: ndarray, n_rounds: int | None = None) ndarray

Predict using the fitted LESSB regressor.

Parameters

Xnp.ndarray of shape (n_samples, n_features)

The input samples to predict.

n_roundsint, optional

The number of boosting stages to use for prediction. If None, all stages are used.

Returns

np.ndarray of shape (n_samples,)

The predicted values.

class less.LESSARegressor(n_subsets: int = 20, n_estimators: int = 100, local_estimator: str | Callable[[], Any] = 'linear', global_estimator: str | Callable[[], Any] | None = 'xgboost', cluster_method: str | Callable[[...], Any] = 'tree', val_size: float | None = None, kernel_coeff: float | None = 0.1, min_neighbors: int = 10, random_state: int | RandomState | None = None)

LESSV (Learning with Subset Stacking Averaging) Regressor.

This regressor implements the averaging variant of the LESS algorithm. It trains multiple iterations of local and global models and averages their predictions.

Parameters

n_subsetsint, default=20

Number of local subsets to create for training.

n_estimatorsint, default=100

The number of averaging iterations to perform.

local_estimatorstr or callable, default=’linear’

The local estimator for modeling data subsets.

global_estimatorstr or callable or None, default=’xgboost’

The global meta-estimator for combining local model predictions.

cluster_methodstr or callable, default=’tree’

The method for selecting subset centers.

val_sizefloat, optional

The proportion of the dataset to reserve for the global estimator.

kernel_coefffloat or None, default=0.1

The RBF kernel coefficient for distance weighting.

min_neighborsint, default=10

The minimum number of neighbors for each local subset.

random_stateint or np.random.RandomState, optional

Controls the randomness for reproducibility.

Attributes

n_features_in_int

The number of features seen during fit().

feature_names_in_np.ndarray of shape (n_features_in_,)

Names of features seen during fit().

_local_models_iterationslist[list[LocalModel]]

A list containing the lists of local models for each iteration.

_global_models_iterationslist[Any]

A list containing the global model for each iteration.

fit(X: ndarray, y: ndarray, sample_weight: ndarray | None = None) LESSARegressor

Fit the LESSA regressor using model averaging.

Parameters

Xnp.ndarray of shape (n_samples, n_features)

The training input samples.

ynp.ndarray of shape (n_samples,)

The target values.

sample_weightnp.ndarray of shape (n_samples,), optional

Sample weights. Not currently used.

Returns

LESSARegressor

The fitted regressor.

predict(X: ndarray, n_estimators: int | None = None) ndarray

Predict using the fitted LESSA regressor.

This method averages the predictions of all trained iterations.

Parameters

Xnp.ndarray of shape (n_samples, n_features)

The input samples to predict.

n_estimatorsint, optional

The number of iterations to use for prediction. If None, all available iterations are used.

Returns

np.ndarray of shape (n_samples,)

The averaged predicted values.