美文网首页
sklearn 错误集合

sklearn 错误集合

作者: sttech | 来源:发表于2019-04-29 09:31 被阅读0次
ValueError: Expected 2D array, got 1D array instead:
错误图示
  • 问题: 对模型进行预测的时候出现
xPred = [102, 6]
yPred = regr.predict(xPred)

会出现以下错误

ValueError: Expected 2D array, got 1D array instead:
array=[102 6].
Reshape your data either using array.reshape(-1, 1) if your data has a single feature or array.reshape(1, -1) if it contains a single sample.

解决方法

xPred = [100,6]
xPred = np.array(xPred).reshape(1,-1)
yPred = regr.predict(xPred)

原因是新版sklearn中所有的数据都应该是二维矩阵,需要使用.reshape(1,-1)进行转换。

相关文章

  • sklearn 错误集合

    ValueError: Expected 2D array, got 1D array instead: 问题: ...

  • ImportError: cannot import name

    今天加载 from sklearn.externals import joblib 报如下错误 ImportErr...

  • 4. 机器学习之特征选择-Python代码

    1. 特征选择------sklearn代码 1.1 特征选择------方差法 忽略warning错误 运行结...

  • 错误集合

    Commit failed with error: did not match any file(s) known...

  • 错误集合

    1.dyld: Library not loaded: @rpath/libswiftCore.dylib R...

  • 错误集合

    1 我的代码错误原因

  • 错误集合

    CocoaPods报错:The dependency AFNetworking is not used in an...

  • 错误集合

    错误一:英文描述 中文描述:大体意思就是这个App缺少一个获取私有(敏感)数据的权限描述,需要我们在info.pl...

  • 错误集合

    1、composer 报 Failed to decode response: zlib_decode(): da...

  • 错误集合

    spring boot 解决后台返回 json 到前台出现中文乱码的问题 微信 登录 Scope 参数错误或没有 ...

网友评论

      本文标题:sklearn 错误集合

      本文链接:https://www.haomeiwen.com/subject/rigrnqtx.html