polynomial_detrender#
Component that removes trends from time series by fitting a polynomial to the data.
Module Contents#
Classes Summary#
Removes trends from time series by fitting a polynomial to the data. |
Contents#
- class evalml.pipelines.components.transformers.preprocessing.polynomial_detrender.PolynomialDetrender(degree=1, random_seed=0, **kwargs)[source]#
Removes trends from time series by fitting a polynomial to the data.
- Parameters
degree (int) – Degree for the polynomial. If 1, linear model is fit to the data. If 2, quadratic model is fit, etc. Defaults to 1.
random_seed (int) – Seed for the random number generator. Defaults to 0.
Attributes
hyperparameter_ranges
{ “degree”: Integer(1, 3)}
modifies_features
False
modifies_target
True
name
Polynomial Detrender
training_only
False
Methods
Constructs a new component with the same parameters and random state.
Returns the default parameters for this component.
Describe a component and its parameters.
Fits the PolynomialDetrender.
Removes fitted trend from target variable.
Adds back fitted trend to target variable.
Loads component at file path.
Returns boolean determining if component needs fitting before calling predict, predict_proba, transform, or feature_importances.
Returns the parameters which were used to initialize the component.
Saves component at file path.
Removes fitted trend from target variable.
- clone(self)#
Constructs a new component with the same parameters and random state.
- Returns
A new instance of this component with identical parameters and random state.
- default_parameters(cls)#
Returns the default parameters for this component.
Our convention is that Component.default_parameters == Component().parameters.
- Returns
Default parameters for this component.
- Return type
dict
- describe(self, print_name=False, return_dict=False)#
Describe a component and its parameters.
- Parameters
print_name (bool, optional) – whether to print name of component
return_dict (bool, optional) – whether to return description as dictionary in the format {“name”: name, “parameters”: parameters}
- Returns
Returns dictionary if return_dict is True, else None.
- Return type
None or dict
- fit(self, X, y=None)[source]#
Fits the PolynomialDetrender.
- Parameters
X (pd.DataFrame, optional) – Ignored.
y (pd.Series) – Target variable to detrend.
- Returns
self
- Raises
ValueError – If y is None.
- fit_transform(self, X, y=None)[source]#
Removes fitted trend from target variable.
- Parameters
X (pd.DataFrame, optional) – Ignored.
y (pd.Series) – Target variable to detrend.
- Returns
- The first element are the input features returned without modification.
The second element is the target variable y with the fitted trend removed.
- Return type
tuple of pd.DataFrame, pd.Series
- inverse_transform(self, y)[source]#
Adds back fitted trend to target variable.
- Parameters
y (pd.Series) – Target variable.
- Returns
- The first element are the input features returned without modification.
The second element is the target variable y with the trend added back.
- Return type
tuple of pd.DataFrame, pd.Series
- Raises
ValueError – If y is None.
- static load(file_path)#
Loads component at file path.
- Parameters
file_path (str) – Location to load file.
- Returns
ComponentBase object
- needs_fitting(self)#
Returns boolean determining if component needs fitting before calling predict, predict_proba, transform, or feature_importances.
This can be overridden to False for components that do not need to be fit or whose fit methods do nothing.
- Returns
True.
- property parameters(self)#
Returns the parameters which were used to initialize the component.
- save(self, file_path, pickle_protocol=cloudpickle.DEFAULT_PROTOCOL)#
Saves component at file path.
- Parameters
file_path (str) – Location to save file.
pickle_protocol (int) – The pickle data stream format.
- transform(self, X, y=None)[source]#
Removes fitted trend from target variable.
- Parameters
X (pd.DataFrame, optional) – Ignored.
y (pd.Series) – Target variable to detrend.
- Returns
- The input features are returned without modification. The target
variable y is detrended
- Return type
tuple of pd.DataFrame, pd.Series