gtime.feature_extraction
.Exogenous¶
-
class
gtime.feature_extraction.
Exogenous
(exogenous_time_series: pandas.core.frame.DataFrame, method: Optional[str] = None)¶ Reindex
exogenous_time_series
with the index oftime_series
. To check the documentation ofpandas.DataFrame.reindex
and to see which type ofmethod
are available, please refer to the pandas documentation.- Parameters
- exogenous_time_seriespd.DataFrame, shape (n_samples, 1), required
The time series to reindex
- methodstr, optional, default:
None
The method used to re-index. This must be a method used by the
pandas.DataFrame.reindex
method.
Examples
>>> import pandas as pd >>> from gtime.feature_extraction import Exogenous >>> ts = pd.DataFrame([0, 1, 2, 3, 4, 5], index=[3, 4, 5, 6, 7, 8]) >>> exog_ts = pd.DataFrame([10, 8, 1, 3, 2, 7]) >>> exog = Exogenous(exog_ts) >>> exog.fit_transform(ts) 0__Exogenous 3 3.0 4 2.0 5 7.0 6 NaN 7 NaN 8 NaN
>>> exog = Exogenous(exog_ts, method="nearest") >>> exog.fit_transform(ts) 0__Exogenous 3 3 4 2 5 7 6 7 7 7 8 7
Methods
fit
(self, time_series[, y])Fit the estimator.
fit_transform
(self, X[, y])Fit to data, then transform it.
get_feature_names
(self)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)Reindex the
exogenous_time_series
with the index oftime_series
.-
__init__
(self, exogenous_time_series:pandas.core.frame.DataFrame, method:Union[str, NoneType]=None)¶ Initialize self. See help(type(self)) for accurate signature.
-
fit
(self, time_series, 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
Additional fit parameters.
- Returns
- X_newnumpy array of shape [n_samples, n_features_new]
Transformed array.
-
get_feature_names
(self)¶ Return feature names for output features.
- Returns
- output_feature_namesndarray, shape (n_output_features,)
Array of feature names.
-
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¶ Reindex the
exogenous_time_series
with the index oftime_series
.- 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 original
exogenous_time_series
, re-indexed with the index oftime_series
.