【问题标题】:I am stuck with train_test_split of sklearn model_selection我被 sklearn model_selection 的 train_test_split 困住了
【发布时间】:2020-04-24 03:44:02
【问题描述】:
from sklearn.model_selection import train_test_split
x_train, x_test, y_train, y_test = train_test_split(image_data, labels, test_size = 0.2, random_state = 101)

显示错误:

ValueError:当 n_samples=0、test_size=0.2 和 train_size=None 时, 结果火车集将是空的。调整上述任何一项 参数。

【问题讨论】:

  • 告诉你传入的数据好像是空的。最好检查 image_data 和标签。
  • image_datalabels的形状是什么?
  • doc 说:“允许的输入是列表、numpy 数组、scipy-sparse 矩阵或 pandas 数据帧。”你应该检查输入的类型和形状

标签: python python-3.x scikit-learn


【解决方案1】:

n_samples=0 表示您的数据集为空。检查 image_data 变量

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-04-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-09-26
    • 1970-01-01
    • 1970-01-01
    • 2012-05-18
    相关资源
    最近更新 更多