小编ile*_*arn的帖子

在 Python 中使用 XGboost_Regressor 会产生非常好的训练性能,但预测效果较差

我一直在尝试在Python中使用XGBregressor。它是迄今为止我用过的最好的机器学习技术之一。但是,在某些数据集中,我有非常高的训练 R 平方,但它在预测或测试中表现非常差。我尝试过使用伽玛、深度和子采样来降低模型的复杂性或确保其不会过度拟合,但训练和测试之间仍然存在巨大差异。我想知道是否有人可以帮助我解决这个问题:

下面是我正在使用的代码:

from sklearn.model_selection import train_test_split

X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.30,random_state=100)

from sklearn.preprocessing import MinMaxScaler
scaler = MinMaxScaler()
scaler.fit(X_train)


xgb = xgboost.XGBRegressor(colsample_bytree=0.7,
                 gamma=0,                 
                 learning_rate=0.01,
                 max_depth=1,
                 min_child_weight=1.5,
                 n_estimators=100000,                                                                    
                 reg_alpha=0.75,
                 reg_lambda=0.45,
                 subsample=0.8,
                 seed=1000) 
Run Code Online (Sandbox Code Playgroud)

以下是训练与测试的表现:

训练:MAE:0.10 R^2:0.99

测试:MAE:1.47 R^2:-0.89

python regression machine-learning xgboost

3
推荐指数
2
解决办法
4166
查看次数

标签 统计

machine-learning ×1

python ×1

regression ×1

xgboost ×1