• For any query, contact us at
  • +91-9872993883
  • +91-8283824812
  • info@ris-ai.com

Overview of AWS Sagemaker

In this article , we will learning how to create,build ,train and deploy ML Models in AWS SageMaker. It is a cloud machine-learning platform. AWS SageMaker enables developers to quickly and easily create, train, and deploy Machine Learning Models in the cloud.

AWS Sagemaker
In [2]:
# import libraries

import sagemaker
import boto3
from sagemaker.amazon.amazon_estimator import get_image_uri
from sagemaker.session import s3_input,Session
In [3]:
# creating s3 bucket

my_region = boto3.session.Session().region_name
bucket_name = 'myawsbucket2821' # <--- GIVE A UNIQUE NAME FOR YOUR BUCKET
s3 = boto3.resource('s3')
try:
    if  my_region == 'us-east-1':
      s3.create_bucket(Bucket=bucket_name)
    else:
      s3.create_bucket(Bucket=bucket_name, CreateBucketConfiguration={ 'LocationConstraint': my_region })
    print('S3 bucket created successfully')
except Exception as e:
    print('S3 error: ',e)
S3 bucket created successfully
In [4]:
# setting an output path

prefix = 'DEMO-xgboost-dm'
output_path='s3://{}/{}/output'.format(bucket_name,prefix)
print(output_path)
s3://myawsbucket2821/DEMO-xgboost-dm/output
In [5]:
# Download the data to your SageMaker instance

import urllib
import pandas as pd

try:
  urllib.request.urlretrieve ("https://d1.awsstatic.com/tmt/build-train-deploy-machine-learning-model-sagemaker/bank_clean.27f01fbbdf43271788427f3682996ae29ceca05d.csv", "bank_clean.csv")
  print('Success: downloaded bank_clean.csv.')
except Exception as e:
  print('Data load error: ',e)
Success: downloaded bank_clean.csv.
In [6]:
# load the data into a dataframe

try:
  model_data = pd.read_csv('./bank_clean.csv',index_col=0)
  print('Success: Data loaded into dataframe.')
except Exception as e:
    print('Data load error: ',e)
Success: Data loaded into dataframe.
In [7]:
# Shuffle and split the data into training data and test data

import numpy as np
train_data, test_data = np.split(model_data.sample(frac=1, random_state=1729), [int(0.7 * len(model_data))])
print(train_data.shape, test_data.shape)
(28831, 61) (12357, 61)
In [8]:
# creating csv of train data

import os
pd.concat([train_data['y_yes'], train_data.drop(['y_no', 'y_yes'], axis=1)], axis=1).to_csv('train.csv', index=False, header=False)
In [9]:
# storing training data in s3 bucket

boto3.Session().resource('s3').Bucket(bucket_name).Object(os.path.join(prefix, 'train/train.csv')).upload_file('train.csv')
s3_input_train = sagemaker.inputs.TrainingInput(s3_data='s3://{}/{}/train'.format(bucket_name, prefix), content_type='csv')
In [10]:
# creating csv of test data

pd.concat([test_data['y_yes'], test_data.drop(['y_no', 'y_yes'], axis=1)], axis=1).to_csv('test.csv', index=False, header=False)
In [11]:
# storing training data in s3 bucket

boto3.Session().resource('s3').Bucket(bucket_name).Object(os.path.join(prefix, 'test/test.csv')).upload_file('test.csv')
s3_input_test = sagemaker.inputs.TrainingInput(s3_data='s3://{}/{}/test'.format(bucket_name, prefix), content_type='csv')
In [12]:
# Building and Training a Model
# Building a Model

from sagemaker import get_execution_role
sess = sagemaker.Session()
xgboost_container = sagemaker.image_uris.retrieve("xgboost", my_region, "latest")
role = get_execution_role()

xgb = sagemaker.estimator.Estimator(xgboost_container,role,
                                    instance_count=1,
                                    instance_type='ml.m4.4xlarge',
                                    output_path= output_path,
                                    sagemaker_session=sess)
xgb.set_hyperparameters(max_depth=5,
                        eta=0.2,
                        gamma=4,
                        min_child_weight=6,
                        subsample=0.8,silent=0
                        ,objective='binary:logistic',
                        num_round=100)
In [13]:
# Training a Model

xgb.fit({'train': s3_input_train})
2021-08-03 09:10:47 Starting - Starting the training job...
2021-08-03 09:11:10 Starting - Launching requested ML instancesProfilerReport-1627981846: InProgress
......
2021-08-03 09:12:10 Starting - Preparing the instances for training......
2021-08-03 09:13:10 Downloading - Downloading input data...
2021-08-03 09:13:46 Training - Training image download completed. Training in progress.
2021-08-03 09:13:46 Uploading - Uploading generated training modelArguments: train
[2021-08-03:09:13:42:INFO] Running standalone xgboost training.
[2021-08-03:09:13:42:INFO] Path /opt/ml/input/data/validation does not exist!
[2021-08-03:09:13:42:INFO] File size need to be processed in the node: 3.38mb. Available memory size in the node: 56259.62mb
[2021-08-03:09:13:42:INFO] Determined delimiter of CSV input is ','
[09:13:42] S3DistributionType set as FullyReplicated
[09:13:42] 28831x59 matrix with 1701029 entries loaded from /opt/ml/input/data/train?format=csv&label_column=0&delimiter=,
[09:13:42] src/tree/updater_prune.cc:74: tree pruning end, 1 roots, 30 extra nodes, 14 pruned nodes, max_depth=5
[0]#011train-error:0.100482
[09:13:42] src/tree/updater_prune.cc:74: tree pruning end, 1 roots, 30 extra nodes, 14 pruned nodes, max_depth=5
[1]#011train-error:0.099858
[09:13:42] src/tree/updater_prune.cc:74: tree pruning end, 1 roots, 28 extra nodes, 22 pruned nodes, max_depth=5
[2]#011train-error:0.099754
[09:13:42] src/tree/updater_prune.cc:74: tree pruning end, 1 roots, 22 extra nodes, 14 pruned nodes, max_depth=5
[3]#011train-error:0.099095
[09:13:42] src/tree/updater_prune.cc:74: tree pruning end, 1 roots, 28 extra nodes, 12 pruned nodes, max_depth=5
[4]#011train-error:0.098991
[09:13:42] src/tree/updater_prune.cc:74: tree pruning end, 1 roots, 32 extra nodes, 14 pruned nodes, max_depth=5
[5]#011train-error:0.099303
[09:13:42] src/tree/updater_prune.cc:74: tree pruning end, 1 roots, 24 extra nodes, 18 pruned nodes, max_depth=5
[6]#011train-error:0.099684
[09:13:42] src/tree/updater_prune.cc:74: tree pruning end, 1 roots, 30 extra nodes, 22 pruned nodes, max_depth=5
[7]#011train-error:0.09906
[09:13:42] src/tree/updater_prune.cc:74: tree pruning end, 1 roots, 28 extra nodes, 20 pruned nodes, max_depth=5
[8]#011train-error:0.098852
[09:13:42] src/tree/updater_prune.cc:74: tree pruning end, 1 roots, 36 extra nodes, 8 pruned nodes, max_depth=5
[9]#011train-error:0.098679
[09:13:42] src/tree/updater_prune.cc:74: tree pruning end, 1 roots, 20 extra nodes, 16 pruned nodes, max_depth=5
[10]#011train-error:0.098748
[09:13:42] src/tree/updater_prune.cc:74: tree pruning end, 1 roots, 28 extra nodes, 24 pruned nodes, max_depth=5
[11]#011train-error:0.098748
[09:13:42] src/tree/updater_prune.cc:74: tree pruning end, 1 roots, 20 extra nodes, 22 pruned nodes, max_depth=5
[12]#011train-error:0.098748
[09:13:42] src/tree/updater_prune.cc:74: tree pruning end, 1 roots, 30 extra nodes, 10 pruned nodes, max_depth=5
[13]#011train-error:0.09854
[09:13:42] src/tree/updater_prune.cc:74: tree pruning end, 1 roots, 22 extra nodes, 20 pruned nodes, max_depth=5
[14]#011train-error:0.098574
[09:13:42] src/tree/updater_prune.cc:74: tree pruning end, 1 roots, 24 extra nodes, 20 pruned nodes, max_depth=5
[15]#011train-error:0.098609
[09:13:42] src/tree/updater_prune.cc:74: tree pruning end, 1 roots, 32 extra nodes, 16 pruned nodes, max_depth=5
[16]#011train-error:0.098817
[09:13:42] src/tree/updater_prune.cc:74: tree pruning end, 1 roots, 18 extra nodes, 16 pruned nodes, max_depth=5
[17]#011train-error:0.098817
[09:13:42] src/tree/updater_prune.cc:74: tree pruning end, 1 roots, 22 extra nodes, 18 pruned nodes, max_depth=5
[18]#011train-error:0.098679
[09:13:42] src/tree/updater_prune.cc:74: tree pruning end, 1 roots, 30 extra nodes, 16 pruned nodes, max_depth=5
[19]#011train-error:0.098679
[09:13:42] src/tree/updater_prune.cc:74: tree pruning end, 1 roots, 20 extra nodes, 12 pruned nodes, max_depth=5
[20]#011train-error:0.098713
[09:13:42] src/tree/updater_prune.cc:74: tree pruning end, 1 roots, 30 extra nodes, 10 pruned nodes, max_depth=5
[21]#011train-error:0.098505
[09:13:42] src/tree/updater_prune.cc:74: tree pruning end, 1 roots, 30 extra nodes, 14 pruned nodes, max_depth=5
[22]#011train-error:0.098401
[09:13:42] src/tree/updater_prune.cc:74: tree pruning end, 1 roots, 26 extra nodes, 8 pruned nodes, max_depth=5
[23]#011train-error:0.098332
[09:13:42] src/tree/updater_prune.cc:74: tree pruning end, 1 roots, 34 extra nodes, 6 pruned nodes, max_depth=5
[24]#011train-error:0.098332
[09:13:42] src/tree/updater_prune.cc:74: tree pruning end, 1 roots, 24 extra nodes, 6 pruned nodes, max_depth=5
[25]#011train-error:0.09795
[09:13:43] src/tree/updater_prune.cc:74: tree pruning end, 1 roots, 20 extra nodes, 12 pruned nodes, max_depth=5
[26]#011train-error:0.098262
[09:13:43] src/tree/updater_prune.cc:74: tree pruning end, 1 roots, 22 extra nodes, 24 pruned nodes, max_depth=5
[27]#011train-error:0.098193
[09:13:43] src/tree/updater_prune.cc:74: tree pruning end, 1 roots, 8 extra nodes, 24 pruned nodes, max_depth=3
[28]#011train-error:0.097985
[09:13:43] src/tree/updater_prune.cc:74: tree pruning end, 1 roots, 20 extra nodes, 10 pruned nodes, max_depth=5
[29]#011train-error:0.097499
[09:13:43] src/tree/updater_prune.cc:74: tree pruning end, 1 roots, 28 extra nodes, 10 pruned nodes, max_depth=5
[30]#011train-error:0.097638
[09:13:43] src/tree/updater_prune.cc:74: tree pruning end, 1 roots, 18 extra nodes, 22 pruned nodes, max_depth=5
[31]#011train-error:0.097395
[09:13:43] src/tree/updater_prune.cc:74: tree pruning end, 1 roots, 28 extra nodes, 24 pruned nodes, max_depth=5
[32]#011train-error:0.097222
[09:13:43] src/tree/updater_prune.cc:74: tree pruning end, 1 roots, 24 extra nodes, 14 pruned nodes, max_depth=5
[33]#011train-error:0.097118
[09:13:43] src/tree/updater_prune.cc:74: tree pruning end, 1 roots, 14 extra nodes, 20 pruned nodes, max_depth=5
[34]#011train-error:0.097014
[09:13:43] src/tree/updater_prune.cc:74: tree pruning end, 1 roots, 24 extra nodes, 18 pruned nodes, max_depth=5
[35]#011train-error:0.09684
[09:13:43] src/tree/updater_prune.cc:74: tree pruning end, 1 roots, 22 extra nodes, 10 pruned nodes, max_depth=5
[36]#011train-error:0.096667
[09:13:43] src/tree/updater_prune.cc:74: tree pruning end, 1 roots, 20 extra nodes, 18 pruned nodes, max_depth=5
[37]#011train-error:0.096736
[09:13:43] src/tree/updater_prune.cc:74: tree pruning end, 1 roots, 30 extra nodes, 22 pruned nodes, max_depth=5
[38]#011train-error:0.096563
[09:13:43] src/tree/updater_prune.cc:74: tree pruning end, 1 roots, 22 extra nodes, 24 pruned nodes, max_depth=5
[39]#011train-error:0.096355
[09:13:43] src/tree/updater_prune.cc:74: tree pruning end, 1 roots, 10 extra nodes, 36 pruned nodes, max_depth=3
[40]#011train-error:0.096285
[09:13:43] src/tree/updater_prune.cc:74: tree pruning end, 1 roots, 12 extra nodes, 38 pruned nodes, max_depth=4
[41]#011train-error:0.096528
[09:13:43] src/tree/updater_prune.cc:74: tree pruning end, 1 roots, 8 extra nodes, 16 pruned nodes, max_depth=4
[42]#011train-error:0.096355
[09:13:43] src/tree/updater_prune.cc:74: tree pruning end, 1 roots, 22 extra nodes, 26 pruned nodes, max_depth=5
[43]#011train-error:0.096459
[09:13:43] src/tree/updater_prune.cc:74: tree pruning end, 1 roots, 10 extra nodes, 36 pruned nodes, max_depth=5
[44]#011train-error:0.096355
[09:13:43] src/tree/updater_prune.cc:74: tree pruning end, 1 roots, 4 extra nodes, 34 pruned nodes, max_depth=2
[45]#011train-error:0.096216
[09:13:43] src/tree/updater_prune.cc:74: tree pruning end, 1 roots, 24 extra nodes, 20 pruned nodes, max_depth=5
[46]#011train-error:0.096077
[09:13:43] src/tree/updater_prune.cc:74: tree pruning end, 1 roots, 18 extra nodes, 14 pruned nodes, max_depth=5
[47]#011train-error:0.0958
[09:13:43] src/tree/updater_prune.cc:74: tree pruning end, 1 roots, 10 extra nodes, 10 pruned nodes, max_depth=5
[48]#011train-error:0.095904
[09:13:43] src/tree/updater_prune.cc:74: tree pruning end, 1 roots, 14 extra nodes, 16 pruned nodes, max_depth=5
[49]#011train-error:0.095904
[09:13:43] src/tree/updater_prune.cc:74: tree pruning end, 1 roots, 10 extra nodes, 34 pruned nodes, max_depth=4
[50]#011train-error:0.095834
[09:13:43] src/tree/updater_prune.cc:74: tree pruning end, 1 roots, 10 extra nodes, 16 pruned nodes, max_depth=5
[51]#011train-error:0.095765
[09:13:43] src/tree/updater_prune.cc:74: tree pruning end, 1 roots, 10 extra nodes, 8 pruned nodes, max_depth=5
[52]#011train-error:0.095904
[09:13:43] src/tree/updater_prune.cc:74: tree pruning end, 1 roots, 14 extra nodes, 6 pruned nodes, max_depth=5
[53]#011train-error:0.095834
[09:13:43] src/tree/updater_prune.cc:74: tree pruning end, 1 roots, 18 extra nodes, 22 pruned nodes, max_depth=5
[54]#011train-error:0.095834
[09:13:43] src/tree/updater_prune.cc:74: tree pruning end, 1 roots, 14 extra nodes, 22 pruned nodes, max_depth=5
[55]#011train-error:0.09573
[09:13:43] src/tree/updater_prune.cc:74: tree pruning end, 1 roots, 10 extra nodes, 30 pruned nodes, max_depth=5
[56]#011train-error:0.095626
[09:13:43] src/tree/updater_prune.cc:74: tree pruning end, 1 roots, 16 extra nodes, 14 pruned nodes, max_depth=5
[57]#011train-error:0.095696
[09:13:43] src/tree/updater_prune.cc:74: tree pruning end, 1 roots, 14 extra nodes, 28 pruned nodes, max_depth=5
[58]#011train-error:0.095661
[09:13:43] src/tree/updater_prune.cc:74: tree pruning end, 1 roots, 14 extra nodes, 24 pruned nodes, max_depth=4
[59]#011train-error:0.095592
[09:13:43] src/tree/updater_prune.cc:74: tree pruning end, 1 roots, 24 extra nodes, 16 pruned nodes, max_depth=5
[60]#011train-error:0.095522
[09:13:43] src/tree/updater_prune.cc:74: tree pruning end, 1 roots, 14 extra nodes, 16 pruned nodes, max_depth=4
[61]#011train-error:0.095383
[09:13:43] src/tree/updater_prune.cc:74: tree pruning end, 1 roots, 8 extra nodes, 20 pruned nodes, max_depth=4
[62]#011train-error:0.095314
[09:13:43] src/tree/updater_prune.cc:74: tree pruning end, 1 roots, 14 extra nodes, 26 pruned nodes, max_depth=5
[63]#011train-error:0.095661
[09:13:43] src/tree/updater_prune.cc:74: tree pruning end, 1 roots, 8 extra nodes, 32 pruned nodes, max_depth=4
[64]#011train-error:0.095661
[09:13:43] src/tree/updater_prune.cc:74: tree pruning end, 1 roots, 32 extra nodes, 18 pruned nodes, max_depth=5
[65]#011train-error:0.095418
[09:13:43] src/tree/updater_prune.cc:74: tree pruning end, 1 roots, 10 extra nodes, 36 pruned nodes, max_depth=3
[66]#011train-error:0.095314
[09:13:43] src/tree/updater_prune.cc:74: tree pruning end, 1 roots, 10 extra nodes, 14 pruned nodes, max_depth=5
[67]#011train-error:0.095349
[09:13:43] src/tree/updater_prune.cc:74: tree pruning end, 1 roots, 6 extra nodes, 28 pruned nodes, max_depth=3
[68]#011train-error:0.095314
[09:13:43] src/tree/updater_prune.cc:74: tree pruning end, 1 roots, 0 extra nodes, 28 pruned nodes, max_depth=0
[69]#011train-error:0.095314
[09:13:43] src/tree/updater_prune.cc:74: tree pruning end, 1 roots, 10 extra nodes, 32 pruned nodes, max_depth=3
[70]#011train-error:0.095383
[09:13:43] src/tree/updater_prune.cc:74: tree pruning end, 1 roots, 22 extra nodes, 12 pruned nodes, max_depth=5
[71]#011train-error:0.095453
[09:13:43] src/tree/updater_prune.cc:74: tree pruning end, 1 roots, 16 extra nodes, 12 pruned nodes, max_depth=5
[72]#011train-error:0.095349
[09:13:43] src/tree/updater_prune.cc:74: tree pruning end, 1 roots, 8 extra nodes, 24 pruned nodes, max_depth=4
[73]#011train-error:0.095245
[09:13:43] src/tree/updater_prune.cc:74: tree pruning end, 1 roots, 10 extra nodes, 14 pruned nodes, max_depth=5
[74]#011train-error:0.095175
[09:13:43] src/tree/updater_prune.cc:74: tree pruning end, 1 roots, 8 extra nodes, 18 pruned nodes, max_depth=4
[75]#011train-error:0.095071
[09:13:43] src/tree/updater_prune.cc:74: tree pruning end, 1 roots, 22 extra nodes, 22 pruned nodes, max_depth=5
[76]#011train-error:0.095175
[09:13:43] src/tree/updater_prune.cc:74: tree pruning end, 1 roots, 18 extra nodes, 30 pruned nodes, max_depth=5
[77]#011train-error:0.095002
[09:13:43] src/tree/updater_prune.cc:74: tree pruning end, 1 roots, 14 extra nodes, 20 pruned nodes, max_depth=4
[78]#011train-error:0.095037
[09:13:43] src/tree/updater_prune.cc:74: tree pruning end, 1 roots, 10 extra nodes, 32 pruned nodes, max_depth=5
[79]#011train-error:0.095037
[09:13:43] src/tree/updater_prune.cc:74: tree pruning end, 1 roots, 22 extra nodes, 24 pruned nodes, max_depth=5
[80]#011train-error:0.095002
[09:13:43] src/tree/updater_prune.cc:74: tree pruning end, 1 roots, 14 extra nodes, 20 pruned nodes, max_depth=5
[81]#011train-error:0.094794
[09:13:43] src/tree/updater_prune.cc:74: tree pruning end, 1 roots, 22 extra nodes, 24 pruned nodes, max_depth=5
[82]#011train-error:0.094759
[09:13:43] src/tree/updater_prune.cc:74: tree pruning end, 1 roots, 20 extra nodes, 20 pruned nodes, max_depth=5
[83]#011train-error:0.094933
[09:13:43] src/tree/updater_prune.cc:74: tree pruning end, 1 roots, 20 extra nodes, 10 pruned nodes, max_depth=5
[84]#011train-error:0.09469
[09:13:43] src/tree/updater_prune.cc:74: tree pruning end, 1 roots, 22 extra nodes, 22 pruned nodes, max_depth=5
[85]#011train-error:0.094759
[09:13:43] src/tree/updater_prune.cc:74: tree pruning end, 1 roots, 22 extra nodes, 24 pruned nodes, max_depth=5
[86]#011train-error:0.094482
[09:13:43] src/tree/updater_prune.cc:74: tree pruning end, 1 roots, 14 extra nodes, 16 pruned nodes, max_depth=5
[87]#011train-error:0.094447
[09:13:43] src/tree/updater_prune.cc:74: tree pruning end, 1 roots, 0 extra nodes, 20 pruned nodes, max_depth=0
[88]#011train-error:0.094482
[09:13:43] src/tree/updater_prune.cc:74: tree pruning end, 1 roots, 16 extra nodes, 24 pruned nodes, max_depth=5
[89]#011train-error:0.094378
[09:13:43] src/tree/updater_prune.cc:74: tree pruning end, 1 roots, 0 extra nodes, 28 pruned nodes, max_depth=0
[90]#011train-error:0.094343
[09:13:43] src/tree/updater_prune.cc:74: tree pruning end, 1 roots, 8 extra nodes, 28 pruned nodes, max_depth=4
[91]#011train-error:0.094274
[09:13:43] src/tree/updater_prune.cc:74: tree pruning end, 1 roots, 10 extra nodes, 20 pruned nodes, max_depth=5
[92]#011train-error:0.094239
[09:13:43] src/tree/updater_prune.cc:74: tree pruning end, 1 roots, 16 extra nodes, 32 pruned nodes, max_depth=5
[93]#011train-error:0.094169
[09:13:43] src/tree/updater_prune.cc:74: tree pruning end, 1 roots, 14 extra nodes, 28 pruned nodes, max_depth=5
[94]#011train-error:0.094169
[09:13:43] src/tree/updater_prune.cc:74: tree pruning end, 1 roots, 10 extra nodes, 14 pruned nodes, max_depth=5
[95]#011train-error:0.094204
[09:13:43] src/tree/updater_prune.cc:74: tree pruning end, 1 roots, 0 extra nodes, 28 pruned nodes, max_depth=0
[96]#011train-error:0.094204
[09:13:43] src/tree/updater_prune.cc:74: tree pruning end, 1 roots, 26 extra nodes, 20 pruned nodes, max_depth=5
[97]#011train-error:0.093927
[09:13:43] src/tree/updater_prune.cc:74: tree pruning end, 1 roots, 0 extra nodes, 38 pruned nodes, max_depth=0
[98]#011train-error:0.093927
[09:13:43] src/tree/updater_prune.cc:74: tree pruning end, 1 roots, 0 extra nodes, 32 pruned nodes, max_depth=0
[99]#011train-error:0.093892

2021-08-03 09:14:10 Completed - Training job completed
Training seconds: 45
Billable seconds: 45
In [14]:
# Deploy the model

xgb_predictor = xgb.deploy(initial_instance_count=1,instance_type='ml.m4.xlarge')
-------------!
In [15]:
# Prediction

from sagemaker.serializers import CSVSerializer

test_data_array = test_data.drop(['y_no', 'y_yes'], axis=1).values #load the data into an array
xgb_predictor.serializer = CSVSerializer() # set the serializer type
predictions = xgb_predictor.predict(test_data_array).decode('utf-8') # predict!
predictions_array = np.fromstring(predictions[1:], sep=',') # and turn the prediction into an array
print(predictions_array.shape)
(12357,)
In [16]:
# Evaluate model performance

cm = pd.crosstab(index=test_data['y_yes'], columns=np.round(predictions_array), rownames=['Observed'], colnames=['Predicted'])
tn = cm.iloc[0,0];
fn = cm.iloc[1,0];
tp = cm.iloc[1,1];
fp = cm.iloc[0,1];
p = (tp+tn)/(tp+tn+fp+fn)*100
print("\n{0:<20}{1:<4.1f}%\n".format("Overall Classification Rate: ", p))
Overall Classification Rate: 89.5%

In [16]:
# Clean up (optional)

# Delete endpoint

xgb_predictor.delete_endpoint(delete_endpoint_config=True)

# Delete training artifacts and S3 bucket

bucket_to_delete = boto3.resource('s3').Bucket(bucket_name)
bucket_to_delete.objects.all().delete()
Out[16]:
[{'ResponseMetadata': {'RequestId': 'WQ967SDXVF0RGCG1',
   'HostId': 'Nr3KByFsidaqdiBF6CiuYqKX4gKpXNl8Eqqg6Ub5h+Xk3sIJgADzwczUTkQHCR/ONDcOFBX+2Bc=',
   'HTTPStatusCode': 200,
   'HTTPHeaders': {'x-amz-id-2': 'Nr3KByFsidaqdiBF6CiuYqKX4gKpXNl8Eqqg6Ub5h+Xk3sIJgADzwczUTkQHCR/ONDcOFBX+2Bc=',
    'x-amz-request-id': 'WQ967SDXVF0RGCG1',
    'date': 'Tue, 03 Aug 2021 09:30:16 GMT',
    'content-type': 'application/xml',
    'transfer-encoding': 'chunked',
    'server': 'AmazonS3',
    'connection': 'close'},
   'RetryAttempts': 0},
  'Deleted': [{'Key': 'DEMO-xgboost-dm/output/xgboost-2021-08-03-09-10-46-971/output/model.tar.gz'},
   {'Key': 'DEMO-xgboost-dm/output/xgboost-2021-08-03-09-10-46-971/profiler-output/system/training_job_end.ts'},
   {'Key': 'DEMO-xgboost-dm/output/xgboost-2021-08-03-09-10-46-971/profiler-output/framework/training_job_end.ts'},
   {'Key': 'DEMO-xgboost-dm/test/test.csv'},
   {'Key': 'DEMO-xgboost-dm/output/xgboost-2021-08-03-09-10-46-971/profiler-output/system/incremental/2021080309/1627981980.algo-1.json'},
   {'Key': 'DEMO-xgboost-dm/train/train.csv'}]}]

Resources You Will Ever Need