A simple example of training/predicting a classification model through the use of the AWS Sagemaker service. The use of the Loko Sagemaker extension will enable simple and intuitive integration.
CONFIGURATION
In order to connect to AWS Sagemaker APIs we need to setup the configuration file "config.json" with an account information as following:
{
"main": {
"environment": {
"AWS_ACCESS_KEY_ID": "<insert your key here>",
"AWS_SECRET_ACCESS_KEY": "<insert your key here>",
"ROLE": "<insert your key here>",
"BUCKET": "<insert your key here>",
"REGION_NAME": "<insert your key here>"
}
}
}
TRAIN
First we choose the reference dataset, which in this case will be iris dataset, very common in Data Science:
In the second step we do a little preprocessing to indicate the target variable to the component that will be in charge of training the Sagemaker model. Next we create batches with the Grouper block.
Finally we use the Loko Sagemaker extension to invoke the AWS Sagemaker Rest API for initializing and training the Machine Learning model.
PREDICT
As for prediction, we select the dataset to be predicted; if the target viariable is present we exclude it via a Selector block and in the end we submit the data to do prediction to the Loko Sagemaker block with the following configuration:
DELETE
Once the Sagemaker API operations are finished, if there is no need to keep the objects created in the cloud, they can be deleted via the delete service in the following procedure: