pyts.preprocessing.MinMaxScaler

class pyts.preprocessing.MinMaxScaler(sample_range=(0, 1))[来源]

通过对每个样本进行缩放至给定范围来转换样本。

参数:
sample_range : tuple (min, max) (default = (0, 1))

转换后数据的期望范围。

示例

>>> from pyts.preprocessing import MinMaxScaler
>>> X = [[1, 5, 3, 2, 9, 6, 4, 7],
...      [1, -2, 3, 2, 2, 1, 0, 2]]
>>> scaler = MinMaxScaler()
>>> scaler.transform(X)
array([[0.   , 0.5  , 0.25 , 0.125, 1.   , 0.625, 0.375, 0.75 ],
       [0.6  , 0.   , 1.   , 0.8  , 0.8  , 0.6  , 0.4  , 0.8  ]])

方法

__init__([sample_range]) 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_output(*[, transform]) Set output container.
set_params(**params) Set the parameters of this estimator.
transform(X) Scale samples of X according to sample_range.
__init__(sample_range=(0, 1))[来源]

初始化自身。查看 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 of shape (n_samples, n_features)

输入样本。

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

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

**fit_params : dict

额外的拟合参数。

返回值:
X_new : 形状为(n_samples, n_features_new)的ndarray数组

转换后的数组。

get_params(deep=True)

获取此估计器的参数。

参数:
deep : bool, default=True

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

返回值:
params : dict

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

set_output(*, transform=None)

设置输出容器。

参见Introducing the set_output API 了解如何使用该API的示例。

参数:
transform : {“default”, “pandas”}, default=None

配置transformfit_transform的输出格式。

  • “default”: 转换器的默认输出格式
  • “pandas”: 输出为DataFrame
  • None: 保持转换配置不变
返回值:
self : 估计器实例

估计器实例。

set_params(**params)

设置此估计器的参数。

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

参数:
**params : dict

估计器参数。

返回值:
self : 估计器实例

估计器实例。

transform(X)[来源]

根据sample_range缩放X的样本。

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

待缩放的数据。

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

缩放后的数据。

使用pyts.preprocessing.MinMaxScaler的示例

Scalers

Scalers

缩放器