pyts.preprocessing.InterpolationImputer

class pyts.preprocessing.InterpolationImputer(missing_values=nan, strategy='linear')[source]

Impute missing values using interpolation.

Parameters:
missing_values : None, np.nan, integer or float (default = np.nan)

The placeholder for the missing values. All occurrences of missing_values will be imputed. If an integer or a float, the input data must not contain NaN or infinity values.

strategy : str or int (default = ‘linear’)

Specifies the kind of interpolation as a string (‘linear’, ‘nearest’, ‘zero’, ‘slinear’, ‘quadratic’, ‘cubic’, ‘previous’, ‘next’, where ‘zero’, ‘slinear’, ‘quadratic’ and ‘cubic’ refer to a spline interpolation of zeroth, first, second or third order; ‘previous’ and ‘next’ simply return the previous or next value of the point) or as an integer specifying the order of the spline interpolator to use. Default is ‘linear’.

Examples

>>> import numpy as np
>>> from pyts.preprocessing import InterpolationImputer
>>> X = [[1, None, 3, 4], [8, None, 4, None]]
>>> imputer = InterpolationImputer()
>>> imputer.transform(X)
array([[1., 2., 3., 4.],
       [8., 6., 4., 2.]])

Methods

__init__([missing_values, strategy]) Initialize self.
fit([X, y]) Pass.
fit_transform(X[, y]) Fit to data, then transform it.
get_params([deep]) Get parameters for this estimator.
set_params(**params) Set the parameters of this estimator.
transform(X) Perform imputation using interpolation.
__init__(missing_values=nan, strategy='linear')[source]

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

fit(X=None, y=None)[source]

Pass.

Parameters:
X

Ignored

y

Ignored

Returns:
self : object
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, shape = (n_samples, n_timestamps)

Univariate time series.

y : None or array-like, shape = (n_samples,) (default = None)

Target values (None for unsupervised transformations).

**fit_params : dict

Additional fit parameters.

Returns:
X_new : array

Transformed array.

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 : dict

Parameter names mapped to their values.

set_params(**params)

Set the parameters of this estimator.

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

Parameters:
**params : dict

Estimator parameters.

Returns:
self : estimator instance

Estimator instance.

transform(X)[source]

Perform imputation using interpolation.

Parameters:
X : array-like, shape = (n_samples, n_timestamps)

Data with missing values.

Returns:
X_new : array-like, shape = (n_samples, n_timestamps)

Data without missing values.

Examples using pyts.preprocessing.InterpolationImputer