【发布时间】:2022-01-10 00:58:40
【问题描述】:
我正在尝试拆分我的数据并创建一个保留集。显示的错误出现在 holdout 行上,我不知道为什么。
分为训练集、测试集和保留集
train_set, test_set = train_test_split((new_df,(.8 * len(new_df))))
holdout = train_set.sample(frac=0.2, random_state=10)
train_set = train_set.drop(holdout.index)
【问题讨论】:
-
好吧,
train_set是一个列表,而不是像您预期的那样具有sample方法的任何类的实例。train_test_split是什么? -
我们应该如何知道这些变量是什么?
-
一个古老的
print(train_set)声明会很快告诉你出了什么问题......
标签: python random-forest sample