How to extract metrics from training XGBoost model in sagemaker

0

Hi, I am trying to set up an XGBoost estimator as following

estimator = XGBoost(
    entry_point="code/train_sagemaker.py",
    role=role,
    instance_count=1,
    instance_type="ml.m5.large", # Not needed here?
    framework_version="1.7-1",
    dependencies=['code/regressionFunctions.py'],
    base_job_name=base_job_name,
    hyperparameters=hyperparameters,
    metric_definitions=metric_definitions,
)

estimator.fit(s3_input_train)

however, I get an error

ClientError: An error occurred (ValidationException) when calling the CreateTrainingJob operation: You can't override the metric definitions for Amazon SageMaker algorithms. Please retry the request without specifying metric definitions.

Here's how I call the model in my entrypoint file

        xgb_regressor = XGBRegressor(**params).fit(self.featuresTrain, self.labelTrain.iloc[:, 0],
                                          eval_set=[(self.featuresTest, self.labelTest.iloc[:, 0])], eval_metric=['rmse', 'mae'], early_stopping_rounds=20)#Extract label column to prevent warning 

When I leave out the option for metric definitions, I am unable to get the metrics for my model. I can extract them myself from the log file, but I also want to use the HyperparameterTuner to tune my models. How can I output metrics so I can extract them>

danuML
asked 4 months ago51 views
No Answers

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions