python-3.x - 如何修复 ValueError:找到包含 0 个样本的数组
问题描述
当我尝试训练模型时,我对尝试使用 sklearn 运行线性回归的 python 真的很陌生:
regressIt.fit(X_train, Y_train)
它抛出以下异常:
ValueError: Found array with 0 sample(s) (shape=(0, 546)) while a minimum of 1 is required.
我究竟做错了什么?
提前致谢。
解决方案
好的,我想我明白了
X=np.array(X).reshape((-1,1)) Should be this instead of ((1,-1)) Not sure why yet?
Y=np.array(Y).reshape((-1,1))
#Also this
print(str(regr.predict(X_test)))
推荐阅读
- r - 将一个数据帧中的单元格值与另一数据帧中的相应单元格值连接起来
- javascript - 如果 id 与值在同一个数组中,如何在 JSON 块中找到值?
- django - React Redux 简单的 GET Api 调用
- postgresql - Postgres 执行计划图片
- android - 向数据库中插入数据时如何将数据插入到表的前面?
- postgresql - 如何在谷歌云中设置保险库和 Postgres 以获得正确的权限?
- npm - 为什么提交 package-lock.json 会消除 npm SignalR 安装错误?
- python-2.7 - selenium 以无头模式下载 csv 文件,它不起作用
- c# - c# 为可为空的布尔值赋值
- java - 赋值运算符链的理解