LECA.estimators.PolynomialRegression

class LECA.estimators.PolynomialRegression(polynomials: int | List[int] | None = None, fit_intercept: bool = True, copy_X: bool = True, n_jobs: int | None = None, positive: bool = False)

Bases: LinearRegression

Estimator Object which accepts polynomial feature inputs and selects specified polynomial features to use for fitting.

__init__(polynomials: int | List[int] | None = None, fit_intercept: bool = True, copy_X: bool = True, n_jobs: int | None = None, positive: bool = False)

Constructor for PolynomialRegression

Parameters:
  • polynomials (Optional[Union[int, List[int]]]) –

    int or list of int indices from PolynomialFeatures to use as model features. If None all polynomial features are used.

    Default value None.

  • **kwargs (kwargs) – Arguments to pass on to LinearRegression model (see docs).

fit(X, y, sample_weight=None) LinearRegression

Take polynomial feature input X, select only the declared polynomials from model initialization, and fit to those with a LinearRegression estimator.

Parameters:
  • X (array-like of shape (n_samples, n_features)) – Polynomial input feature vectors.

  • y (array-like of shape (n_samples, n_objectives)) – True labels.

  • sample_weight (array-like of shape (n_samples, n_objectives)) – Sample weights.

Returns:

Fitted (trained) PolynomialRegression object.

Return type:

LinearRegression

predict(X)

Predict using the linear model.

Parameters:

X (array-like or sparse matrix, shape (n_samples, n_features)) – Samples.

Returns:

C – Returns predicted values.

Return type:

array, shape (n_samples,)

set_fit_request(*, sample_weight: bool | None | str = '$UNCHANGED$') PolynomialRegression

Request metadata passed to the fit method.

Note that this method is only relevant if enable_metadata_routing=True (see sklearn.set_config()). Please see User Guide on how the routing mechanism works.

The options for each parameter are:

  • True: metadata is requested, and passed to fit if provided. The request is ignored if metadata is not provided.

  • False: metadata is not requested and the meta-estimator will not pass it to fit.

  • 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_weight parameter in fit.

Returns:

self – The updated object.

Return type:

object

set_score_request(*, sample_weight: bool | None | str = '$UNCHANGED$') PolynomialRegression

Request metadata passed to the score method.

Note that this method is only relevant if enable_metadata_routing=True (see sklearn.set_config()). Please see User Guide on how the routing mechanism works.

The options for each parameter are:

  • True: metadata is requested, and passed to score if provided. The request is ignored if metadata is not provided.

  • False: metadata is not requested and the meta-estimator will not pass it to score.

  • 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_weight parameter in score.

Returns:

self – The updated object.

Return type:

object