标签:
(1)用sklearn进行逻辑回归时,建立完模型,由于要预测的数据量很大,无法一次全部预测,只能每次预测一个样本数据,
在每次以列表形式输入数据进行预测时出现:
/Users/donganlan/anaconda/lib/python2.7/site-packages/sklearn/utils/validation.py:386:
for line in hp:
DeprecationWarning: Passing 1d arrays as data is deprecated in 0.17 and willraise 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. DeprecationWarning)
解决办法:将输入数据由列表形式改成shape(1,-1)形式
line = re.sub(r‘\\N‘, ‘0‘, line)
linearr = line.strip().split(‘,‘)
xpredict = [float(i) for i in linearr][2:118]
xpredictnd =np.array(xpredict).reshape(1,-1)
ypredict = grid.predict(xpredictnd)
标签:
原文地址:http://www.cnblogs.com/harvey888/p/5850421.html