对于具有形状的数据
(num_samples,features)
,
MinMaxScaler
从
sklearn.preprocessing
但是,当用同样的方法对具有形状的时间序列数据进行处理时
(num_samples, time_steps,features)
,sklearn将给出一个错误。
from sklearn.preprocessing import MinMaxScaler
import numpy as np
#Making artifical time data
x1 = np.linspace(0,3,4).reshape(-1,1)
x2 = np.linspace(10,13,4).reshape(-1,1)
X1 = np.concatenate((x1*0.1,x2*0.1),axis=1)
X2 = np.concatenate((x1,x2),axis=1)
X = np.stack((X1,X2))
#Trying to normalize
scaler = MinMaxScaler()
X_norm = scaler.fit_transform(X) <--- error here
ValueError:找到了dim为3的数组。需要MinMaxScaler<=2.
这个
post
有点像
(timeseries-timeseries.min())/(timeseries.max()-timeseries.min())
然而,它只适用于只有一个特性的数据。因为我的数据有不止一个特征,所以这个方法不起作用。
如何规范化具有多个特征的时间序列数据?