SageMaker Canvas Demo

Marketing Response Campaign (Classification)

Overview

In this demo, we will learn how to use SageMaker Canvas to build no-code classification models to predict customers' response to marketing campaigns.

Datasets can be downloaded here:

Prerequisite

First, we need to launch the SageMaker Canvas application. For that, navigate to SageMaker service and then in the Canvas screen, select "Open Canvas":

Search Sagemaker

Open Canvas

It will open the Canvas app in new tab:

Canvas App

If you click on the bottom left arrow ( > ) button you can see the full name of the icons.

Canvas Icon1 Canvas Icon2

Import and manage data

In this exercise, we will create a model that solve a binary classification problem. Model predicts whether a lead will convert into a sale or not based on the different marketing activities/metrics captured for that lead by the marketing campaigns. Download the web marketing data and lead data files to your local desktop/laptop. We will upload these 2 files later in the Sagemaker Canvas for training the model. Let’s have a look into the data. open both csv files in your laptop.

Download Links:

Data Exploration

Lead Data

LeadData.csv file provides data about the lead and each lead has a unique ProspectID associated with it.

It provides information including job role (JobRole), lead profile (LeadProfile) , whether they used marketing promotion or not (UsedPromo), region ( Region ), unique Id ( prospectID ) and whether they converted into a sales or not ( Converted ) etc. This "converted" field is our target feature for model prediction.

https://s3.amazonaws.com/weclouddata/images/canvas/marketing_response_campaign/Lead_Data.png

Web Marketing Data

WebMarketingData.csv file provides data on what all different marketing activities / matrices were performed by the lead under different campaigns run by marketing team.

It provides data including the last campaign activity performed by the lead ( LastCampaignActivity ), number of page views per visit ( PageViewsPerVisit ), total time spend on website ( TotalTimeOnWebsite ), whether the lead attended the marketing event or not ( AttendMarketingEvent ), whether the lead viewed the advertisement or not ( ViewedAdvertisement ) etc.

https://s3.amazonaws.com/weclouddata/images/canvas/marketing_response_campaign/Campaign_Data.png

Please Note: In both files, the field "ProspectID" joins each lead in LeadData.csv file to WebMarketingData.csv file.

Create and upload datasets

Now let's import both of these two files in Sagemaker Canvas to train the model.

Join Datasets

Now we can join both datasets which create a new dataset for model training .

We can use this new dataset to train our model.

Build a Model

Now, let's start building our model.

Evaluate the model

We evaluate how well our model performed on our data before we start using it to make predictions by using the following:

Scroll down through the "Column impact" order list that depicts which feature has high impact on the inference of target feature using this model. We can click on any column and change the target value ( 0 or 1 ) to see the column impact:

Evaluate Model

Click on the "Scoring" tab. Here we can see on the right hand side, model accuracy insights are provided to gain more insights of the model.

Evaluate Model

Now click on the "Advanced metrics" tab. It gives us the information like below:

Evaluate Model

SageMaker Canvas uses confusion matrices to help you visualise when a model makes predictions correctly. As this is a binary classification problem hence advance metrics like F1 score, Accuracy, Precision, recall and AUC are shown above. We can switch the "Positive Class"

Make Prediction

We can do a single prediction or batch prediction using Sagemaker Canvas. We do a single prediction here. click on the "Predict" button and then select "Single Prediction" tab. Sagemaker canvas automatically generates a sample data and predicts the target feature ( converted ) for this data. As you can see here, it predicted "No" as converted target feature for this sample data.

Model Prediction

Model Prediction

We can play around with this sample data and update the prediction after changing the data.

For example I changed "Usedpromo" from "NoPromo" to "UsedPromo"and hit the update button to predict the target feature again. This time it predicted "Yes" as converted target feature for this changed sample data.

Model Prediction

OPTIONAL: Build another version of the Model using Standard build option

SageMaker Canvas supports building multiple version of a model. Now we create a new version of the above model but this time we train it using the "Standard build" option.

Click on the "Add version" button and it will create a V2 ( in draft status ) of this model:

Model V2

Now our model switch to Version 2. Below screen appears. Now, In the Select dataset page, select the our Marketing Campaign-Joined dataset and click Select dataset

Model V2

Now build model screen appear ( like shown below ) and de-select the "ProspectID" feature as shown below ( as we don’t want to train our model with this feature ):

Model V2

Now click on the dropdown of "Quick build" button and select "Standard build" option. Now click on "Standard build" button:

Model V2

Evaluate Model

Now wait for model build completion as it will take around 45 minutes or less:

Evaluate Model

Once the model build is complete, it will jump to the "Analyze" page with the accuracy score and column impact by default.

Evaluate this model same as the previous model; by navigating to "Scoring" and "Advance Metrics" tabs. You can use this model to do either batch prediction or single prediction as well.