Reputation: 33
I am new to Sagemaker and trying to set up a hyperparameter tuning job for xgboost algorithm in Sagemaker. I have very imbalanced data (98% majority class, 2% minority class) and would like to use the "scale_pos_weight" parameter but the below error happens.
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.
I have upgraded the sagemaker package, restarted my kernel (I am using juptyer notebook), and instance but the problem still exists.
Does anyone have any ideas why this error happens and how I can fix it? I appreciate the help.
Here is my code that I followed from an example in 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)
Upvotes: 1
Views: 1565
Reputation: 748
Based on the Sagemaker developer documentation, https://docs.aws.amazon.com/sagemaker/latest/dg/xgboost-tuning.html, the hyperparameter scale_pos_weight
is NOT tunable. The only parameters that you can tune are given in the link.
Upvotes: 2