PANDAS错误:"n_sample =1,test_size=0.25,train_size=无,(...)调整上述任何参数,“

lfapxunr  于 2023-02-07  发布在  其他
关注(0)|答案(1)|浏览(272)

我正在使用下面的代码,请参见下面的错误。代码:
please see my data in this link

import pandas as pd
df=pd.read_csv('Ecommerce Customers')
df.head()

X=[['Avg. Session Length', 'Time on App','Time on Website']]

y=['Yearly Amount Spent']

from sklearn.model_selection import train_test_split

X_train, X_test, y_train, y_test = train_test_split( X, y, test_size=0.25, random_state=101)

输出:

ValueError: With n_samples=1, test_size=0.25 and train_size=None, the resulting train set will be empty. Adjust any of the aforementioned parameters.

我在论坛上读到过在这种情况下扩展数据,但我不知道如何做。

eh57zj3b

eh57zj3b1#

创建X和y时需要添加“df”:

X=df[['Avg. Session Length', 'Time on App','Time on Website']]

y=df['Yearly Amount Spent']

这样X和y就是 Dataframe /序列,否则它们只是列名称的列表。

相关问题