在 Ubuntu 下全新安装 Anaconda... 在使用 Scikit-Learn 进行分类任务之前,我正在以各种方式预处理我的数据。
from sklearn import preprocessing
scaler = preprocessing.MinMaxScaler().fit(train)
train = scaler.transform(train)
test = scaler.transform(test)
这一切都很好,但如果我有一个我想要分类的新样本(下面的温度)(因此我想以同样的方式进行预处理,那么我得到
temp = [1,2,3,4,5,5,6,....................,7]
temp = scaler.transform(temp)
然后我收到弃用警告...
DeprecationWarning: Passing 1d arrays as data is deprecated in 0.17
and will raise ValueError in 0.19. Reshape your data either using
X.reshape(-1, 1) if your data has a single feature or X.reshape(1, -1)
if it contains a single sample.
所以问题是我应该如何重新调整这样的单个样本?
我想另一种选择(不是很好)是......
temp = [temp, temp]
temp = scaler.transform(temp)
temp = temp[0]
但我确信有更好的方法。