No code ML - Make accurate predictions with Amazon SageMaker Canvas
Tags: aws, machinelearning, analytics, business
Published: 2023-04-02 11:36:45

## Empowering you to make decisions with no code ML

Organizations are becoming more data-driven no matter where your company is in the data analytics maturity cycle you may be thinking about your first use case. Whether you work for a startup, consulting, government or banking you may be helping your leaders make decisions to migrate a workload from on-prem to the cloud, doing some data engineering to build a pipeline, testing AI POCs or even making predictions from clean data in a data lake.

Today we will explore how you can get started easily in machine learning as a business user to test a hypothesis and confidently make decisions with no-code ML to empower you to get insights quickly without the need to have a computer science background.

### Lesson Outcomes

You will learn how to:

* Set up the environment to use machine learning 

* Select a target variable to build your model

* Get started using Amazon SageMaker Canvas to make predictions

* Retrieve model evaluation metrics, draw model insights and view predictions


### What is Machine Learning?

In a nutshell machine learning helps you to explore patterns in your dataset. There are two types of machine learning which are:

**Supervised Learning:** Linear regression when you have a labelled dataset and you would like to make prediction from a dependent variable that is an integer or continuous variable. Classification is the opposite where you are trying to make predictions from an outcome variable that is a categorical variable.

**Unsupervised Learning:** Is when you have an unlabelled dataset and you would like to draw patterns from it. For example, clustering and princicpal component analysis.

You are welcome to explore courses in machine learning at [AWS Skillbuilder](https://explore.skillbuilder.aws/learn)

### What is Amazon SageMaker Canvas?

Amazon SageMaker Canvas empowers business analysts to make machine learning predictions with a user-friendly interface without the need to program or write any [code](https://aws.amazon.com/sagemaker/canvas/). You may simply bring in your own dataset and use a pre-trained custom model in Amazon SageMaker Canvas.

### Why Amazon SageMaker Canvas?

Amazon SageMaker Canvas fosters the bridge between technical teams and the business sponsor for greater collaboration between data scientists, engineers and business analysts. This enables greater alignment in agile between business requirements and technical strategy to deliver end-user goals.

You may take advantage of AWS Free Tier for 2 months which includes 160 session hours per month free under [AWS Free Tier](https://aws.amazon.com/sagemaker/canvas/pricing/) with your [AWS account](https://dev.to/aws-builders/getting-started-with-aws-a-sweet-journey-5cjj).

### Who should use it?

Anyone is welcome to use Amazon SageMaker Canvas especially if you are a BA, decision maker, executive leader and you don't have a machine learning background. You do not need to program in any language using [ready to use ML models](https://aws.amazon.com/sagemaker/canvas/).

However if you are a data scientist, developer, machine learning engineer or solution architect familiar with programming, you may wish to use [custom models](https://aws.amazon.com/sagemaker/canvas/).

### What are the common use cases?

As a business user your organization can explore use cases with Amazon SageMaker Canvas that include:

* Detect customer sentiment e.g. call transcripts
* Prediction e.g. customer churn and fraudulent applications
* Extract information from documents e.g. invoices, forms
* Classify images e.g. insurance claim assessments
* Classify text e.g. support tickets
* Demand forecasting

### Problem Statement

Let's start with the data analytics workflow using [CRISP-DM](https://www.datascience-pm.com/crisp-dm-2/) to define the business problem:

* Is this insurance claim form fraudulent?


### Dataset

This vehicle insurance claim fraud detection dataset is from [Kaggle.com](https://www.kaggle.com/datasets/shivamb/vehicle-claim-fraud-detection?resource=download).

This is a classification problem and the outcome variable i.e.**FraudFound_P** we are trying to predict, is a continuous variable with the binary values O = Not fraudulent and 1 = Fraudulent claim.

### Solution Architecture

This is the solution overview of how to bring in your own dataset to make predictions with Amazon SageMaker canvas.


![architecture](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/j61pwfnlmmbdj0pp12gk.jpg)

### Tutorial 1: Setting up the environment


* Step 1: Sign into your AWS account for IAM user. If you don't have an AWS IAM admin user account you may create one [here](https://dev.to/aws-builders/creating-your-first-iam-admin-user-and-user-group-in-your-aws-account-machine-learning-part-1-3cne).

* Step 2: You may follow the getting started [tutorial](https://aws.amazon.com/getting-started/hands-on/machine-learning-tutorial-generate-predictions-without-writing-code/) to create a stack using AWS Cloud Formation to set up the environment.

Accept the default settings for US East (N.Virginia) region and check the box to acknowledge the terms and conditions. Click **Create stack**.

![create stack](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cz9neqhrn7xv2w3jht1c.jpg)

* Step 3: The stack is being created and will take about 1 hour to complete.


![Being created](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/w6kunutaugztawp1l4qp.jpg)


![created](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/a8d0yym2mx8zl5n20hsr.jpg)


### Tutorial 2: Get started as a business user

* Step 1:  Type into the search bar **Amazon SageMaker**.


On the left-handside, click **Canvas** and ensure that you are operating under AWS region US East (N.Virginia).


![canvas](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/h1d09u0xfp7kocs5zyx8.jpg)

* Step 2: Open the Canvas to launch it.

![open](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mnhkarl0wbj47h44w92l.jpg)

It will take a few minutes to launch the canvas.


![message](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4rw6mp3vbdjjamudd1xm.jpg)

* Step 3: You may read the tutorials to help you get started.


![turorials](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/be8u5do3mvvpz817jr6j.jpg)


* Step 4: Upload your dataset into the Amazon S3 bucket.
![new](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/h93fvvy92d7jrj3jcekw.jpg)

* Step 5: Select **Datasets**.


![daatsets](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4mas8oj10iq8ke14zgoh.jpg)

Click **Import** to upload your dataset.


![Import data](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/42kpsn6mwg1wjplabt77.jpg)

Click **Amazon S3** to upload a dataset stored in Amazon S3 bucket.


![mys3](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/e14l7pwbvj0jyy8tz73h.jpg)

Check the box against the file and click **Import data**.


![import daat](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/u43iofmgh0q4tlw6wpww.jpg)


### Tutorial 3: Start making predictions from your dataset


* Step 1: Choose from **Ready to use models**

With [ready to use models](https://docs.aws.amazon.com/sagemaker/latest/dg/canvas-ready-to-use-models.html) you may bring in your own dataset and take advantage of pre-trained models that use AWS services including Amazon Textract, Amazon Rekogntion and Amazon Comprehend to make predictions.


![import](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fw1hq315t4ox50l25b13.jpg)

Step 2: If you cannot locate a ready to use model type the search bar 'Prediction' and select **Create a Custom model**.


![custoim](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bz098fh5hil2uz6o9oci.jpg)

* Step 3: Select **Predictive Analysis** and **Create**.


![predictn](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/607t7k4ibumg8v8ak0aa.jpg)


* Step 4: Click **Select dataset** to start building a model.


![select](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/k4d8y83cyatbz9iuuoln.jpg)

* Step 5: Under the tab **Build**, Choose a **target variable** from the drop-down menu as the outcome variable i.e. 'FraudFound_P' column.



![select target](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xbe5jokg3r36dewg3tod.jpg)


![fraud found p](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/l61zdxt0yzparhykl9th.jpg)

The **model type** infers that this a two category prediction.
Select **Quick Build**.


![quick build](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/c8n6glz87vv89ntt82va.jpg)

It will take between 2-15 minutes to build the prediction model.


![building](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0nauimeld6ile3wc4zfn.jpg)

* Step 6: Under the **Analyze** tab in the section **Overview*, Amazon SageMaker provides details that 96.402 % of the time the 
training results predicts fraud.


![model predicts](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wtm1b2i9j2unpngdct3t.jpg)

In the next tab **Scoring**, you can see the plot of the predicted and actual values. The model insights tell us that when an insurance claim is not fraudulent, the predicted outcome occurs 98.235 % of the time.


![scoring](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7pbwbkrrl7kwcf22fi6m.jpg)

If you click **Advanced Settings**, you may view the Confusion Matrix which provides metrics to evaluate the model to predict the class = 0 (No fraud).

* F1 score = 98.083 %
* Accuracy = 96.402 %
* Precision = 98.230 %
* AUC (Area under the ROC curve) = 0.976
* Recall = 97.931 %

![confusion matrix](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pv64xx4nem6c85s6pst0.jpg)

When we toggle to the class = 1 (Fraud), the evaluation metrics of the model include:

* F1 score = 70.712 %
* Accuracy = 96.072 %
* Precision = 69.072 %
* AUC (Area under the ROC curve) = 0.976
* Recall = 72.432 %


![with fraud](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bi5uofcikowlgi23uzw8.jpg)

* Step 7: On the tab 'Predict' click the button **Predict** to make predictions. Select **Batch predictions** and select your dataset.

View and download the predictions.


![view predictions](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6tnqmc8x3lxorif9g1b6.jpg)

Amazon SageMaker Canvas provides a list of predictions against the classes (Class 0 = no fraud and Class 1 = fraud) on the entire dataset which you may download.


![Iprobability](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qk6cqmdh324veq7dakbs.jpg)

* Step 8: You may also generate predictions by selecting **Single predictions** and Amazon SageMaker Canvas will provide details of the feature importance in descending order of the variables in the dataset.


![fearure importance](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yx78viecr0qx2hntdfzb.jpg)

You may also download the Acutal prediction which is:

* 95.31 % of the time there is no fraudulent insurance claim
* 4.69% of the time there is a fraudulent insurance claim

### Clean up resources

To avoid surprise charges on your AWS billing account at the end of the month, I recommend that you delete the AWS services that you no longer need.

* Step 1: Navigate to your Amazon S3 bucket and click **Empty** to clear the resource.


![click empty](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xvhx9729c83q70zu2rkx.jpg)

* Step 2: Under **My Models** click on the ellipse (3 dots) and delete the model.

![delte tje model](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zjd6jj7k507rohadfrg6.jpg)

* Step 3: Under **User Details**, for each application click **Delete apps** and enter the word 'delete' in the box.


![user](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pz9jry64616rg7xyc7fn.jpg)


![delete app](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/g22q5r7331xoytzm4sev.jpg)

And delete the user.


![delete user](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/o9r3yzsrnf8dngp2lyjl.jpg)

* Step 4: Navigate to **Cloud Formation** by typing the word into the search bar.

Click **Stack** on the left handside, select the radio-dial **CFN-SM-IM-Lambda-Catalog** and then click **delete** to disable all the AWS services that were previously created in that stack.


![delete cloudformation](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/y30pitatzpx1inq97gd3.jpg)

Confirm to delete the Cloudformation stack.


![delete cl](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rsh7pl1r5lyavd9di8io.jpg)

### AWS re:invent 2022 - Machine Learning

If you missed any of the keynotes or workshop sessions from AWS re:invent 2022 you may catch up and watch them on Youtube at this [link](https://www.youtube.com/c/AWSEventsChannel).

You may watch the breakout session 'AWS re:Invent 2022 - Better decisions with no-code ML using SageMaker Canvas' featuring a customer story from Samsung to hear how they implemented Amazon SageMaker Canvas. {% embed https://www.youtube.com/watch?v=vH5xc8C3OX4 %}

You may also hear about democratizing machine learning from the recent AWS re:Invent 2022 [keynote](https://www.youtube.com/watch?v=TL2HtX-FmiQ&t=550s) from Dr Swami Sivasubramanian, VP of analytics, database and ML at AWS.

### AWS SageMaker Canvas Announcement - 30 March 2023

Amazon SageMaker Canvas also supports NLP and computer vision with ready to use models. You may find out more [here](https://aws.amazon.com/about-aws/whats-new/2023/03/amazon-sagemaker-canvas-nlp-cv-use-cases/).

### References

* [Amazon SageMaker Developer Guide](https://docs.aws.amazon.com/sagemaker/latest/dg/canvas-getting-started.html)

* [Amazon Sagemaker Canvas](https://aws.amazon.com/sagemaker/canvas/)

* [Ready to use models](https://docs.aws.amazon.com/sagemaker/latest/dg/canvas-ready-to-use-models.html)

* [Generate ML predictions without writing code](https://aws.amazon.com/getting-started/hands-on/machine-learning-tutorial-generate-predictions-without-writing-code/)

* [Delete an Amazon SageMaker Domain](https://docs.aws.amazon.com/sagemaker/latest/dg/gs-studio-delete-domain.html)

Until the next lesson, Happy Learning! 😁

### What's new this week or coming soon to you 🌎

* AWS Sydney Summit - 4 April 2023. Register and join us for the live stream [here](https://aws.amazon.com/events/summits/sydney/).


![sydney](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2yix3vokjuu64hrrujvj.jpg)

* AWS re:Inforce - June 13-14 2023. Register and [join us](https://reinforce.awsevents.com/).


![reinforce](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5iunjxmujgs23o8zgvmz.jpg)
AWS London Summit - 7 June 2023. Register and [join us](https://aws.amazon.com/events/summits/london/).


![london](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tf274i8f1kgqp83mj13o.jpg)