giotto.time_series
.Resampler¶
-
class
giotto.time_series.
Resampler
(period=2)¶ Time series resampling at regular intervals.
- Parameters
- periodint, default:
2
The sampling period, i.e. one point every period will be kept.
- periodint, default:
Examples
>>> import numpy as np >>> from giotto.time_series import Resampler >>> # Create a noisy signal >>> signal = np.asarray([np.sin(x /40) + np.random.random() ... for x in range(0, 300)]) >>> # Set up the Resampler >>> period = 10 >>> periodic_sampler = Resampler(period=period) >>> # Fit and transform the signal >>> signal_resampled = periodic_sampler.fit_transform(signal) >>> print(signal_resampled.shape) (30,)
Methods
fit
(self, X[, y])Do nothing and return the estimator unchanged.
fit_transform
(self, X[, y])Fit to data, then transform it.
fit_transform_resample
(self, X, y, …)Fit to data, then transform the input and resample the target.
get_params
(self[, deep])Get parameters for this estimator.
resample
(self, y[, X])Resample y.
set_params
(self, \*\*params)Set the parameters of this estimator.
transform
(self, X[, y])Resample X.
transform_resample
(self, X, y)Fit to data, then transform it.
-
__init__
(self, period=2)¶ Initialize self. See help(type(self)) for accurate signature.
-
fit
(self, X, y=None)¶ Do nothing and return the estimator unchanged.
This method is there to implement the usual scikit-learn API and hence work in pipelines.
- Parameters
- Xndarray, shape (n_samples,) or (n_samples, …)
Input data.
- yNone
Ignored.
- Returns
- selfobject
-
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
- Xndarray of shape (n_samples, …)
Input data.
- yNone
There is no need for a target in a transformer, yet the pipeline API requires this parameter.
- Returns
- Xtnumpy array of shape (n_samples, …)
Transformed input.
-
fit_transform_resample
(self, X, y, **fit_params)¶ Fit to data, then transform the input and resample the target. Fits transformer to X and y with optional parameters fit_params and returns a transformed version of X ans a resampled version of y.
- Parameters
- Xndarray of shape (n_samples, …)
Input data.
- yndarray of shape (n_samples, )
Target data.
- Returns
- Xtndarray of shape (n_samples, …)
Transformed input.
- yrndarray of shape (n_samples, …)
Resampled target.
-
get_params
(self, deep=True)¶ Get parameters for this estimator.
- Parameters
- deepboolean, optional
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.
-
resample
(self, y, X=None)¶ Resample y.
- Parameters
- yndarray, shape (n_samples,)
Target.
- XNone
There is no need for input data, yet the pipeline API requires this parameter.
- Returns
- yrndarray, shape (n_samples_new,)
Resampled target.
n_samples_new = n_samples // period
.
-
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.- Returns
- self
-
transform
(self, X, y=None)¶ Resample X.
- Parameters
- Xndarray, shape (n_samples,) or (n_samples, …)
Input data.
- yNone
There is no need for a target, yet the pipeline API requires this parameter.
- Returns
- Xtndarray, shape (n_samples_new, …)
Resampled array.
n_samples_new = n_samples // period
.
-
transform_resample
(self, X, y)¶ 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
- Xndarray of shape (n_samples, …)
Input data.
- yndarray of shape (n_samples, )
Target data.
- Returns
- Xtndarray of shape (n_samples, …)
Transformed input.