【问题标题】:Why i'm getting value error at the time of train_test_split method in linear regression为什么我在线性回归中使用 train_test_split 方法时出现值错误
【发布时间】:2020-07-10 14:52:41
【问题描述】:

enter image description here

当时我正在执行一些测试,我在拆分时遇到值错误

【问题讨论】:

    标签: machine-learning linear-regression prediction valueerror


    【解决方案1】:

    出现此错误是因为您的 X 和 Y 长度不同(这是 train_test_split 所要求的),即 X.shape[0] != Y.shape[0]。 试试这个:

    >>> X.shape
    
    >>> Y.shape
    

    然后解决这个问题:

    • 您必须从 np.array() 内部删除额外的列表 定义 X 或随后使用 以下命令:X = X.reshape(X.shape[1:])。
    • 然后通过运行 X = X.transpose() 转置 X 以获得相等的数字 X 和 Y 中的样本数。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-12-25
      • 1970-01-01
      • 2021-08-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多