Sagemaker XGBoost 超参数调整错误

Sagemaker XGBoost Hyperparameter Tuning Error

我是 Sagemaker 的新手,正在尝试在 Sagemaker 中为 xgboost 算法设置超参数调整作业。我有非常不平衡的数据(98% 多数 class,2% 少数 class),想使用“scale_pos_weight”参数,但出现以下错误。

ClientError: An error occurred (ValidationException) when calling the CreateHyperParameterTuningJob operation: The hyperparameter tuning job that you requested has the following untunable hyperparameters: [scale_pos_weight]. For the algorithm, ---------------.us-east-1.amazonaws.com/xgboost:1, you can tune only [colsample_bytree, lambda, eta, max_depth, alpha, num_round, colsample_bylevel, subsample, min_child_weight, max_delta_step, gamma]. Delete untunable hyperparameters.  

我已经升级了sagemaker包,重启了我的内核(我使用的是juptyer notebook)和实例,但问题仍然存在。

有没有人知道为什么会发生此错误以及我该如何解决?感谢您的帮助。

这是我从 AWS 中的示例中遵循的代码。

sess = sagemaker.Session()
container = get_image_uri(region, 'xgboost', '1.0-1')

xgb = sagemaker.estimator.Estimator(container,
                                    role, 
                                    train_instance_count=1, 
                                    train_instance_type='ml.m4.4xlarge',
                                    output_path='s3://{}/{}/output'.format(bucket, prefix),
                                    sagemaker_session=sess)

xgb.set_hyperparameters(eval_metric='auc',
                        objective='binary:logistic',
                        num_round=100,
                        rate_drop=0.3,
                        tweedie_variance_power=1.4)

hyperparameter_ranges = {'eta': ContinuousParameter(0, 1),
                        'min_child_weight': ContinuousParameter(1, 10),
                        'scale_pos_weight' : ContinuousParameter(700, 800),
                        'alpha': ContinuousParameter(0, 2),
                        'max_depth': IntegerParameter(1, 10),
                        'colsample_bytree' : ContinuousParameter(0.1, 0.9)
                        }
objective_metric_name = 'validation:auc'

tuner = HyperparameterTuner(xgb,
                            objective_metric_name,
                            hyperparameter_ranges,
                            max_jobs=10,
                            max_parallel_jobs=2)

s3_input_train = sagemaker.s3_input(s3_data='s3://{}/{}/train'.format(bucket, prefix), content_type='csv')
s3_input_validation = sagemaker.s3_input(s3_data='s3://{}/{}/validation/'.format(bucket, prefix), content_type='csv')

tuner.fit({'train': s3_input_train, 'validation': s3_input_validation}, include_cls_metadata=False)

根据 Sagemaker 开发人员文档,https://docs.aws.amazon.com/sagemaker/latest/dg/xgboost-tuning.html,超参数 scale_pos_weight 不可调整。您可以调整的唯一参数在 link.

中给出