skpoly.BernsteinFeatures

class skpoly.BernsteinFeatures(*, degree=3, feature_range=(0.0, 1.0), include_bias=False, tensor_product=False)[source]

Bases: _BasePolynomialBasisTransformer

Generate Bernstein polynomial features.

Parameters:
  • degree (int, default=3) – Highest degree of the basis.

  • feature_range (tuple of float, default=(0.0, 1.0)) – Interval [a, b] that bounds the input features.

  • include_bias (bool, default=False) – If True, include the first basis function of each feature.

  • tensor_product (bool, default=False) – If True, append tensor product features for each pair of columns.

n_features_in_

Number of features in the input passed to fit().

Type:

int

feature_range_

Validated feature range.

Type:

tuple of float

n_output_features_

Total number of output features generated by transform().

Type:

int

__init__(*, degree=3, feature_range=(0.0, 1.0), include_bias=False, tensor_product=False)
Parameters:
  • degree (int)

  • feature_range (tuple[float, float])

  • include_bias (bool)

  • tensor_product (bool)

Return type:

None

Methods

__init__(*[, degree, feature_range, ...])

fit(X[, y])

Validate parameters and learn the number of features in X.

fit_transform(X[, y])

Fit to data, then transform it.

get_metadata_routing()

Get metadata routing of this object.

get_params([deep])

Get parameters for this estimator.

set_output(*[, transform])

Set output container.

set_params(**params)

Set the parameters of this estimator.

transform(X)

Transform X into the polynomial basis representation.

fit(X, y=None)

Validate parameters and learn the number of features in X.

fit_transform(X, y=None, **fit_params)

Fit to data, then transform it.

Fits transformer to X and y with optional parameters fit_params and returns a transformed version of X.

Parameters:
  • X (array-like of shape (n_samples, n_features)) – Input samples.

  • y (array-like of shape (n_samples,) or (n_samples, n_outputs), default=None) – Target values (None for unsupervised transformations).

  • **fit_params (dict) – Additional fit parameters.

Returns:

X_new – Transformed array.

Return type:

ndarray array of shape (n_samples, n_features_new)

get_metadata_routing()

Get metadata routing of this object.

Please check User Guide on how the routing mechanism works.

Returns:

routing – A MetadataRequest encapsulating routing information.

Return type:

MetadataRequest

get_params(deep=True)

Get parameters for this estimator.

Parameters:

deep (bool, default=True) – If True, will return the parameters for this estimator and contained subobjects that are estimators.

Returns:

params – Parameter names mapped to their values.

Return type:

dict

set_output(*, transform=None)

Set output container.

See sphx_glr_auto_examples_miscellaneous_plot_set_output.py for an example on how to use the API.

Parameters:

transform ({"default", "pandas", "polars"}, default=None) –

Configure output of transform and fit_transform.

  • ”default”: Default output format of a transformer

  • ”pandas”: DataFrame output

  • ”polars”: Polars output

  • None: Transform configuration is unchanged

Added in version 1.4: “polars” option was added.

Returns:

self – Estimator instance.

Return type:

estimator instance

set_params(**params)

Set the parameters of this estimator.

The method works on simple estimators as well as on nested objects (such as Pipeline). The latter have parameters of the form <component>__<parameter> so that it’s possible to update each component of a nested object.

Parameters:

**params (dict) – Estimator parameters.

Returns:

self – Estimator instance.

Return type:

estimator instance

transform(X)

Transform X into the polynomial basis representation.