【问题标题】:Sagemaker XGBoost Hyperparameter Tuning ErrorSagemaker XGBoost 超参数调整错误
【发布时间】:2021-02-11 11:51:52
【问题描述】:

我是 Sagemaker 的新手,正在尝试在 Sagemaker 中为 xgboost 算法设置超参数调整作业。我有非常不平衡的数据(98% 多数类,2% 少数类)并且想使用“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)

【问题讨论】:

    标签: python xgboost amazon-sagemaker hyperparameters


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 2020-06-10
      • 1970-01-01
      • 2021-12-15
      • 2020-01-20
      • 2022-08-16
      • 1970-01-01
      • 2021-06-08
      • 1970-01-01
      • 2021-07-04
      相关资源
      最近更新 更多