Python 如何使用列车测试分割?修复错误n_示例=0

Python 如何使用列车测试分割?修复错误n_示例=0,python,machine-learning,scikit-learn,train-test-split,Python,Machine Learning,Scikit Learn,Train Test Split,我试图将正在处理的数据拆分为训练集和测试集,但在使用train_test_split函数时,我得到的错误是n_samples=0 这是我的密码: X_train, X_test, y_train, y_test = model_selection.train_test_split(summary, labels, test_size=0.35) 摘要和标签是列表,将它们转换为数组后,我得到的形状是: (1248,) (1248,) 它们都有1248个值。有人能告诉我为什么它不工作吗?谢谢 错

我试图将正在处理的数据拆分为训练集和测试集,但在使用train_test_split函数时,我得到的错误是n_samples=0

这是我的密码:

X_train, X_test, y_train, y_test = model_selection.train_test_split(summary, labels, test_size=0.35)
摘要和标签是列表,将它们转换为数组后,我得到的形状是:

(1248,)
(1248,)
它们都有1248个值。有人能告诉我为什么它不工作吗?谢谢

错误消息:

With n_samples=0, test_size=0.35 and train_size=None, the resulting train set will be empty. Adjust any of the aforementioned parameters

适用于我,请检查此选项是否适用于您:

from sklearn.model_selection import train_test_split
import numpy as np

# dummy examples
summary, labels = np.arange(0,1248), np.arange(0,1248)

X_train, X_test, y_train, y_test = train_test_split(summary, labels, test_size=0.35)
使用字符串列表进行测试

summary, labels = ["hello"]*1248, ["test"]*1248

我将
np.arrange(01248)
部分添加到我的代码中,并得到以下错误:无法在像object这样的字节上使用字符串模式摘要列表包含文本,因为我正在尝试训练一袋单词模型。希望这些信息有帮助。@John检查编辑,用新的字符串列表替换这两个列表。它仍然有效。