发现输入变量的样本数量不一致:[301056, 253]

发布于 2025-01-16 13:55:25 字数 1297 浏览 2 评论 0原文

我正在研究机器学习,为了训练我的数据,我使用了这些函数。

我已经做了什么:

我已经应用替换其中的 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]

enter image description here

I did replacing the X in it!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

遗失的美好 2025-01-23 13:55:25

您收到此错误是因为 X 中的行数与 data_target 中的行数不同。
他们应该是平等的。

You are getting this error because number of rows in X not the same in data_target.
They should be equal.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文