发现输入变量的样本数量不一致:[301056, 253]
我正在研究机器学习,为了训练我的数据,我使用了这些函数。
我已经做了什么:
我已经应用替换其中的 X 值。
代码:
from sklearn.model_selection import train_test_split
x_train, x_test, y_train, y_test = train_test_split(X, data_target, test_size = 0.1, random_state = 3)
代码下方显示错误:
ValueError Traceback (most recent call last)
<ipython-input-37-f5111ea343c6> in <module>()
1 from sklearn.model_selection import train_test_split
----> 2 x_train, x_test, y_train, y_test = train_test_split(X, data_target, test_size = 0.1, random_state = 3)
2 frames
/usr/local/lib/python3.7/dist-packages/sklearn/utils/validation.py in check_consistent_length(*arrays)
332 raise ValueError(
333 "Found input variables with inconsistent numbers of samples: %r"
--> 334 % [int(l) for l in lengths]
335 )
336
ValueError: Found input variables with inconsistent numbers of samples: [301056, 253]
错误:发现输入变量的样本数量不一致:[301056, 253]
我确实替换了其中的 X!
I am working on ML and for training my data, I used these functions.
What I already did in this:
I already apply replacing the value of X in it.
Code:
from sklearn.model_selection import train_test_split
x_train, x_test, y_train, y_test = train_test_split(X, data_target, test_size = 0.1, random_state = 3)
Error shown below the code:
ValueError Traceback (most recent call last)
<ipython-input-37-f5111ea343c6> in <module>()
1 from sklearn.model_selection import train_test_split
----> 2 x_train, x_test, y_train, y_test = train_test_split(X, data_target, test_size = 0.1, random_state = 3)
2 frames
/usr/local/lib/python3.7/dist-packages/sklearn/utils/validation.py in check_consistent_length(*arrays)
332 raise ValueError(
333 "Found input variables with inconsistent numbers of samples: %r"
--> 334 % [int(l) for l in lengths]
335 )
336
ValueError: Found input variables with inconsistent numbers of samples: [301056, 253]
Error: Found input variables with inconsistent numbers of samples: [301056, 253]
I did replacing the X in it!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您收到此错误是因为 X 中的行数与 data_target 中的行数不同。
他们应该是平等的。
You are getting this error because number of rows in X not the same in data_target.
They should be equal.