InterpolationImputer#

class pyts.preprocessing.InterpolationImputer(missing_values: int | float | None = nan, strategy: str | int = 'linear')[source]#

Impute missing values using interpolation.

Parameters:
missing_valuesNone, 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.

strategystr 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’.

Each strategy requires a minimum number of non-missing values per sample to be well-defined: 1 for ‘zero’, ‘previous’, ‘next’ and ‘nearest’; 2 for ‘linear’ and ‘slinear’; 3 for ‘quadratic’; 4 for ‘cubic’; and order + 1 for an integer spline order. A ValueError is raised if a sample does not have enough non-missing values for the selected strategy.

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])

fit([X, y])

Pass.

fit_transform(X[, y])

Fit to data, then transform it.

get_metadata_routing()

Get metadata routing of this object.

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: int | float | None = nan, strategy: str | int = 'linear') → None[source]#
fit(X: ArrayLike | None = None, y: ArrayLike | None = None) → Self[source]#

Pass.

Parameters:
X

Ignored

y

Ignored

Returns:
selfobject
transform(X: ArrayLike) → NDArray[float64][source]#

Perform imputation using interpolation.

Parameters:
Xarray-like, shape = (n_samples, n_timestamps)

Data with missing values.

Returns:
X_newarray-like, shape = (n_samples, n_timestamps)

Data without missing values.

Examples using pyts.preprocessing.InterpolationImputer#

Imputer

Imputer