有关使用sklearn LogisticRegression出现的 DeprecationWarning:

原Warning如下:

C:\Python27\lib\site-packages\sklearn\utils\validation.py:395: 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.


之前输入的测试代码如下:

from sklearn.externals import joblib
from array import array
from sklearn.linear_model import LogisticRegression
import numpy as np

x = [24, 0, 251, 38, 20, 52, 168, 1]
print type(x)


classifier =(joblib.load('classifier.model'))
result = classifier.predict(x)
print result[0]

改正输入x 

x = [[24, 0, 251, 38, 20, 52, 168, 1]]
这样就没有DeprecationWarning了。

分析:主要问题在 

classifier.predict(x)

对于我的情况,虽然是一个sample ,但是也要规范输入x =  [ [sample1 features] , [sample2 features] ... [samplen features] ].

  • 11
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值