python在机器学习中用predict函数,输入上述代码会报错 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.DeprecationWarning)print("the predict value is ",LR.predict([7.97,8,44.3,45.8,64.9,38.2,40,40,6]))
解决方案是:把predict函数中的参数变成数组即可
print("the predict value is ",LR.predict(np.array([7.97,8,44.3,45.8,64.9,38.2,40,40,6]).reshape((1,-1))))