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 + 1for an integer spline order. AValueErroris 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.