in code/cv.py [0:0]
def evaluation(training_jobs, sm_client):
"""Evaluates and calculate the performance for the cross validation training jobs.
Args:
training_jobs: array of submitted training jobs
sm_client: boto3 sagemaker client
Returns:
Average score from the training jobs collection in the given input
"""
scores = []
for job in training_jobs:
job_detail = sm_client.describe_training_job(TrainingJobName=job._current_job_name)
metrics = job_detail['FinalMetricDataList']
score = [x['Value'] for x in metrics if x['MetricName'] == 'test:score'][0]
scores.append(score)
np_scores = np.array(scores)
# Calculate the score by taking the average score across the performance of the training job
score_avg = np.average(np_scores)
logging.info(f'average model test score:{score_avg};')
return score_avg