首页 > 解决方案 > 如何修复 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.

我究竟做错了什么?

提前致谢。

标签: python-3.xscikit-learn

解决方案


好的,我想我明白了
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)))


推荐阅读