# `gtime.feature_extraction`.Polynomial¶

class `gtime.feature_extraction.``Polynomial`(degree: int = 2)

Compute the polynomial feature_extraction, of a degree equal to the input `degree`. Wrapper of `sklearn.preprocessing.PolynomialFeatures` but returns a `pd.DataFrame`.

Parameters
degreeint, optional, default: `2`

The degree of the polynomial feature_extraction.

Attributes
powers_

Examples

```>>> import pandas as pd
>>> from gtime.feature_extraction import Polynomial
>>> ts = pd.DataFrame([0, 1, 2, 3, 4, 5])
>>> pol = Polynomial(degree=3)
>>> pol.fit_transform(ts)
0__Polynomial  1__Polynomial  2__Polynomial  3__Polynomial
0            1.0            0.0            0.0            0.0
1            1.0            1.0            1.0            1.0
2            1.0            2.0            4.0            8.0
3            1.0            3.0            9.0           27.0
4            1.0            4.0           16.0           64.0
5            1.0            5.0           25.0          125.0
```

Methods

 `fit`(self, time_series[, y]) Fit the estimator. `fit_transform`(self, X[, y]) Fit to data, then transform it. `get_feature_names`(self[, input_features]) Return feature names for output features `get_params`(self[, deep]) Get parameters for this estimator. `set_params`(self, \*\*params) Set the parameters of this estimator. `transform`(self, time_series) Compute the polynomial feature_extraction of `time_series`, up to a degree equal to `degree`.
`__init__`(self, degree:int=2)

Initialize self. See help(type(self)) for accurate signature.

`fit`(self, time_series:pandas.core.frame.DataFrame, y=None)

Fit the estimator.

Parameters
time_seriespd.DataFrame, shape (n_samples, n_features)

Input data.

yNone

There is no need of a target in a transformer, yet the pipeline API requires this parameter.

Returns
selfobject

Returns self.

`fit_transform`(self, 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
Xnumpy array of shape [n_samples, n_features]

Training set.

ynumpy array of shape [n_samples]

Target values.

**fit_paramsdict

Returns
X_newnumpy array of shape [n_samples, n_features_new]

Transformed array.

`get_feature_names`(self, input_features=None)

Return feature names for output features

Parameters
input_featureslist of string, length n_features, optional

String names for input features if available. By default, “x0”, “x1”, … “xn_features” is used.

Returns
output_feature_nameslist of string, length n_output_features
`get_params`(self, deep=True)

Get parameters for this estimator.

Parameters
deepbool, default=True

If True, will return the parameters for this estimator and contained subobjects that are estimators.

Returns
paramsmapping of string to any

Parameter names mapped to their values.

`set_params`(self, **params)

Set the parameters of this estimator.

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

Parameters
**paramsdict

Estimator parameters.

Returns
selfobject

Estimator instance.

`transform`(self, time_series:pandas.core.frame.DataFrame) → pandas.core.frame.DataFrame

Compute the polynomial feature_extraction of `time_series`, up to a degree equal to `degree`.

Parameters
time_seriespd.DataFrame, shape (n_samples, 1), required

The input DataFrame. Used only for its index.

Returns
time_series_tpd.DataFrame, shape (n_samples, 1)

The computed polynomial feature_extraction.