【发布时间】:2016-05-07 01:08:42
【问题描述】:
在 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]
但我相信还有更好的方法。
【问题讨论】:
-
嗯……你自己回答了。它在警告中:
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.如果您的数据不是 numpy 数组,请先使用 np.array(data)。
标签: python scikit-learn deprecation-warning