我正在使用下面的代码,请参见下面的错误。代码:
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.
我在论坛上读到过在这种情况下扩展数据,但我不知道如何做。
1条答案
按热度按时间eh57zj3b1#
创建X和y时需要添加“df”:
这样X和y就是 Dataframe /序列,否则它们只是列名称的列表。