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

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

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

Pass.

Parameters:
X

Ignored

y

Ignored

Returns:
self : object
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:
X : numpy array of shape [n_samples, n_features]

Training set.

y : numpy array of shape [n_samples]

Target values.

**fit_params : dict

Additional fit parameters.

Returns:
X_new : numpy array of shape [n_samples, n_features_new]

Transformed array.

get_params(self, 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 : mapping 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:
**params : dict

Estimator parameters.

Returns:
self : object

Estimator instance.

transform(self, 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