有关使用sklearn LogisticRegression出现的 DeprecationWarning:
生活随笔
收集整理的這篇文章主要介紹了
有关使用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 npx = [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] ].
總結
以上是生活随笔為你收集整理的有关使用sklearn LogisticRegression出现的 DeprecationWarning:的全部內容,希望文章能夠幫你解決所遇到的問題。