pyts.preprocessing.InterpolationImputer

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

使用插值法填补缺失值。

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

缺失值的占位符。所有出现的missing_values都将被填充。如果是整数或浮点数,则输入数据不能包含NaN或无穷大值。

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

指定插值类型,可以是字符串('linear'、'nearest'、'zero'、'slinear'、'quadratic'、'cubic'、'previous'、'next',其中'zero'、'slinear'、'quadratic'和'cubic'分别表示零阶、一阶、二阶或三阶样条插值;'previous'和'next'仅返回该点的前一个或后一个值),也可以是整数,用于指定要使用的样条插值器的阶数。默认为'linear'。

示例

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

方法

__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')[来源]

初始化自身。查看 help(type(self)) 获取准确的签名信息。

fit(X=None, y=None)[来源]

通过。

参数:
X

忽略

y

忽略

返回值:
self : object
fit_transform(X, y=None, **fit_params)

拟合数据,然后进行转换。

使用可选参数fit_params将转换器适配到Xy,并返回转换后的X版本。

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

单变量时间序列。

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

目标值(无监督转换时为None)。

**fit_params : dict

额外的拟合参数。

返回值:
X_new : array

转换后的数组。

get_params(deep=True)

获取此估计器的参数。

参数:
deep : bool, default=True

如果为True,将返回此估计器及其包含的子估计器的参数。

返回值:
params : dict

参数名称映射到对应的值。

set_params(**params)

设置此估计器的参数。

该方法不仅适用于简单的估计器,也适用于嵌套对象(如Pipeline)。后者采用<component>__<parameter>形式的参数,从而可以更新嵌套对象的每个组件。

参数:
**params : dict

估计器参数。

返回值:
self : 估计器实例

估计器实例。

transform(X)[来源]

使用插值法进行缺失值填充。

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

包含缺失值的数据。

返回值:
X_new : array-like, shape = (n_samples, n_timestamps)

无缺失值的数据。

使用pyts.preprocessing.InterpolationImputer的示例

Imputer

缺失值填充器

缺失值填充器