This is a repo to store my implementation and steps using SageMaker (AWS). Objectives in the end:
- Create notebook instance;
- Save dataset to a default Amazon S3 bucket automatically paired with the SageMaker session;
- Submit a training job of an ML model to Amazon EC2;
- Deploy the trained model for prediction by hosting
I'm using the sklearn.datasets.load_digits that consists of digits with 8×8 size, it means 64 features (pixels) and 1 target variable (the number).
- Go to https://console.aws.amazon.com/sagemaker/ to create the jupyter instance
- For the first time, we need to create a single user click on
Set up for single user
, and we have to wait for the platform to create our Domain. - Now, click on
Notebook
→Notebook instances
→Create notebook instance
- Type the
Notebook instance name
and select the cheapestNotebook instance type
(ml.t2.medium) - In
IAM role
chooseCreate new role
andCreate role
- In the end:
Create notebook instance
- Wait until the
Status
is In-Service - Click on
Open JupyterLab
and will open the notebook in your browser - I'm using the kernel
conda_python3
- I download the Jupyter Notebook that I used in my AWS - SageMaker. You can find it here: SageMaker-Predict-Digit.ipynb. The superficial flow representation of the notebook is shown below:
graph TD;
A["Download dataset"] --> B["Load dataset"];
B --> C["Show samples & classes frequencies"];
C --> D["Transform into Pandas DataFrame"];
D --> E["Save on CSV in a bucket S3"];
E --> F["Split dataset (train, val, test)"];
F --> G["Train the model (XGBoost from images_uris)"];
G --> H["Deploy the model (endpoint)"];
H --> I["Evaluate the model"];
To avoid incurring unnecessary charges, use the AWS Management Console
to delete the endpoints and resources that you created while running. I deleted everything created as shown below:
-
Go to the SageMaker console:
a. Under
Inference
, chooseEndpoints
anddelete
.b. Under
Inference
, chooseEndpoint configurations
anddelete
.c. Under
Inference
, chooseModels
anddelete
.d. Under
Notebook
, chooseNotebook instances
anddelete
. -
Go to the S3 console and delete the bucket created (you need emptying before deleting)
- Go to the CloudWatch console →
Log Groups
and delete everything starting with/aws/sagemaker/
Created by BrenoAV