我正在尝试对xgboost模型进行超参数调整。我开始使用以下参数范围来进行AWS Sagemaker超参数调整:
xgb.set_hyperparameters(eval_metric='auc',
objective='binary:logistic',
early_stopping_rounds=500,
rate_drop=0.1,
colsample_bytree=0.8,
subsample=0.75,
min_child_weight=0)
hyperparameter_ranges = {'eta': ContinuousParameter(0.01, 0.3),
'lambda': ContinuousParameter(0.1, 2),
'alpha': ContinuousParameter(0.5, 2),
'max_depth': IntegerParameter(5, 10),
'num_round': IntegerParameter(500, 2000)}
objective_metric_name = 'validation:auc'
tuner = HyperparameterTuner(xgb,
objective_metric_name,
hyperparameter_ranges,
max_jobs=10,
max_parallel_jobs=3,
tags=[{'Key': 'Application', 'Value': 'cxxx'}])
并使用以下超参数集获得最佳模型:
{
"alpha": "1.4009334471163981",
"eta": "0.05726016655019904",
"lambda": "1.2070623852474922",
"max_depth": "7",
"num_round": "1052"
}
出于好奇,我将这些超参数连接到xgboost python包中,如下所示:
xgb_model = xgb.XGBClassifier(max_depth = 7,
silent = False,
random_state = 42,
n_estimators = 1052,
learning_rate = 0.05726016655019904,
objective = 'binary:logistic',
verbosity = 1,
reg_alpha = 1.4009334471163981,
reg_lambda = 1.2070623852474922,
rate_drop=0.1,
colsample_bytree=0.8,
subsample=0.75,
min_child_weight=0
)
我重新训练了模型,并意识到从后者获得的结果要比从SageMaker获得的结果更好。 xgboost(验证集的auc):0.766 SageMaker最佳模型(验证集的总和):0.751
我想知道SageMaker为什么表现这么差?如果SageMaker通常执行的性能比xgboost python软件包差,那么人们通常如何进行xgboost超参数调整?感谢您的提示!
答案 0 :(得分:0)
我的第一个猜测是您使用的是XGBoost的不同版本。您正在使用哪个图像?启用脚本模式的开源XGBoost使用0.90。