SeasonalityTransformer¶
-
class
hcrystalball.feature_extraction.
SeasonalityTransformer
(auto=True, freq=None, week_day=None, monthly=None, quarterly=None, yearly=None, weekly=None, month_start=False, month_end=False, quarter_start=False, quarter_end=False, year_start=False, year_end=False)[source]¶ Bases:
sklearn.base.BaseEstimator
,sklearn.base.TransformerMixin
Generate seasonal feature columns using one-hot encoding.
- Parameters
auto (bool) – Automatically generate week_day, monthly, quarterly, yearly, weekly if it makes sense given the data frequency
freq (str) – Frequency of data
week_day (bool) – Whether to add day name as a feature
monthly (bool) – Whether to add month as a feature
quarterly (bool) – Whether to add quarter as a feature
yearly (bool) – Whether to add year as a feature
weekly (bool) – Whether to add week number as a feature
- Raises
ValueError – Error is raised if freq is not in [‘D’, ‘W’, ‘M’,’Q’, ‘Y’, None]
ValueError – Error is raised if freq is not provided when using auto=True
Methods Summary
fit
(X, y)Set fit columns to None
fit_transform
(X[, y])Fit to data, then transform it.
Provide handle to get column names for created data
get_params
([deep])Get parameters for this estimator.
set_params
(**params)Set the parameters of this estimator.
transform
(X)Create seasonal columns from datetime index
Methods Documentation
-
fit
(X, y)[source]¶ Set fit columns to None
- Parameters
X (pandas.DataFrame) – Ignored.
y (numpy.ndarray) – Ignored.
- Returns
self
- Return type
-
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, sparse matrix, dataframe} of shape (n_samples, n_features)) –
y (ndarray of shape (n_samples,), default=None) – Target values.
**fit_params (dict) – Additional fit parameters.
- Returns
X_new – Transformed array.
- Return type
ndarray array of shape (n_samples, n_features_new)
-
get_feature_names
()[source]¶ Provide handle to get column names for created data
- Returns
Name of the generated feature vectors when the transformer is fitted.
- Return type
-
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
mapping of string to any
-
set_params
(**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.
-
transform
(X)[source]¶ Create seasonal columns from datetime index
- Parameters
X (pandas.DataFrame) – Input features.
- Returns
Contains the generated feature vector(s)
- Return type