IndexError:元组索引超出范围(XGBoost)

我正在尝试预测一堆商店的每周销售额。我想使用XGBoost,但我总是遇到这个错误:

IndexError: tuple index out of range

我的代码:

from sklearn.model_selection import train_test_split

features = ["Store",'Dept','Temperature','Fuel_Price','CPI','Unemployment']

y = allmergecopy.Weekly_Sales
X = allmergecopy[features]
X_train, y_train, X_valid, y_valid = train_test_split(y,X,test_size=.2, train_size=.8)

from xgboost import XGBRegressor

my_model = XGBRegressor(n_estimators=100)
my_model.fit(X_train, y_train)

供参考:

y_train.shape = (84314,), X_train.shape = (337256,)

转载请注明出处:http://www.cdylmjg.com/article/20230331/1398039.html