Echo Dot (3rd Gen) - Smart speaker with Alexa - Charcoal

Use your voice to play a song, artist, or genre through Amazon Music, Apple Music, Spotify, Pandora, and others. With compatible Echo devices in different rooms, you can fill your whole home with music.

Buy Now

Wireless Rechargeable Battery Powered WiFi Camera.

Wireless Rechargeable Battery Powered WiFi Camera is home security camera system lets you listen in and talk back through the built in speaker and microphone that work directly through your iPhone or Android Mic.

Buy Now

Visualizing Amazon SageMaker machine learning predictions with Amazon QuickSight

0
85


AWS is excited to announce the general availability of Amazon SageMaker integration in QuickSight. You can now integrate your own Amazon SageMaker ML models with QuickSight to analyze the augmented data and use it directly in your business intelligence dashboards. As a business analyst, data engineer, or data scientist, you can perform ML inference in QuickSight with just a few clicks. This process makes predictions on new data and uses Amazon SageMaker models for different use cases, such as predicting the likelihood of customer churn, scoring leads to prioritize sales activity, and assessing credit risk for loan applications.

Customer use case

Change Healthcare is a leading independent healthcare technology company that provides data and analytics-driven solutions to improve clinical, financial, and patient engagement outcomes in the US healthcare system.

At Change Healthcare “We are leveraging Amazon SageMaker for various machine learning use cases such as reducing overpayment and claim waste.” says Jayant Thomas, Senior Director of AI Engineering. “We’re pleased to see the addition of SageMaker integration in Amazon QuickSight. This strengthens QuickSight as one of the leading solutions for BI, ML insights and dashboard publishing, as it streamlines the workflow and the development cycle in SageMaker-based inferencing architectures.”

Integration of Amazon QuickSight with Amazon Sagemaker

Traditionally, getting the predictions from trained models into a BI tool requires substantial heavy lifting. You have to write code to ETL the data into Amazon Simple Storage Service (Amazon S3), call the inference API to get the predictions, ETL the model output from Amazon S3 to a queryable source, orchestrate this process whenever new data is available, and repeat the workflow for every model. Inference endpoints enable easier consumption of the models, but come at the cost of potentially incurring charges when not in use. Finally, you use third-party tools like Excel to perform analysis and report on the predictions, which makes it difficult to update and share the results to a large number of users. The end-to-end process to get value from the model is undifferentiated and can take days or weeks before the predictions of the models get to the business decision-makers.

The QuickSight integration with Amazon SageMaker feature addresses these pain points by automating the entire data movement and inference pipeline.

To run inferencing on your dataset, you can connect to any of the QuickSight supported data sources (such as Amazon S3, Amazon Athena, Amazon Aurora, Amazon Relational Database Service (Amazon RDS), and Amazon Redshift, and third-party application sources like Salesforce, ServiceNow, and JIRA), select the pretrained Amazon SageMaker model you want to use for prediction, and QuickSight takes care of the rest. After the data ingestion and inference job are complete, you can create visualizations and build reports based on the predictions and share it with business stakeholders, all in an end-to-end workflow. The output of the inference is stored as a QuickSight SPICE dataset and makes it possible to share it with others. You can perform manual, one-off predictions, run predictions on a schedule, or trigger predictions programmatically via the QuickSight dataset APIs when your data refreshes.

This post walks you through a use case of customer churn, in which you predict the likelihood of customers leaving their mobile phone operator. As the provider, if you find out which customer is leaving, you can offer timely incentives to stay, such as a phone upgrade or perhaps having a new feature activated. Incentives are often much more cost-effective than losing and reacquiring a customer. You can use customer interaction and service usage data to build a model that can find those customers most likely to churn.

For this use case, you train an Amazon SageMaker model to predict customer churn, connect your QuickSight to Amazon SageMaker, use the model on your current customer base to identify at-risk customers, and provide predictive dashboards through QuickSight. You don’t need any specialized ML experience to set this up. The walkthrough demonstrates how to build this dashboard with predicted data.

Setting up your Amazon SageMaker environment

To set up your Amazon SageMaker environment, complete the following steps:

  1. On the Amazon SageMaker console, choose Notebook instances.
  2. Choose Create notebook.
  3. For Notebook instance name, enter a name for your instance; for example, QS-sagemaker.
  4. For Notebook instance type, choose ml.t3.medium.
  5. For Choose an IAM role, choose Create a new role.
  6. For S3 bucket, choose Any S3 bucket.

Normally, you should select a specific bucket, but you haven’t created one yet; you do so in the notebook.

  1. Choose Create role.
  2. Choose the Git repositories
  3. For Repository, choose Clone a public Git repository to this notebook instance only.
  4. For Git repository URL, enter https://github.com/aws-samples/quicksight-sagemaker-integration-blog.git.
  5. Leave all other fields at their defaults.
  6. Choose Create notebook instance.

You can now see your list of notebook instances. Wait for your new instance status to show as In Service, which can take up to 5 minutes. You may have to refresh the page, depending on your browser.

  1. Next to your instance, choose Open JupyterLab.

The JupyterLab page opens in your browser.

Running the notebook

To run your notebook, complete the following steps:

  1. On the JupyterLab page, open the quicksight-sagemaker-integration, and choose customer_churn.ipynb.The IPython notebook opens.
  2. In the first cell of the notebook, set the name of your S3 bucket. You need to create an S3 bucket to store your datasets and the model you build, see How do I create an S3 Bucket? This should be within the same region as the Notebook Instance.
    Visualizing Amazon SageMaker machine learning predictions with Amazon QuickSight 1
  3. Read and run all the cells in the notebook.

The notebook includes preprocessing, training the model, and postprocessing steps. It creates the model for you with the name that starts with QS-inference-pipeline-. This is the name of the Amazon SageMaker model that you want to use to perform the inference and augment the dataset in the QuickSight.

Setting up Amazon QuickSight to work with Amazon SageMaker

QuickSight’s integration with Amazon Sagemaker is only available on the Enterprise Edition of Amazon QuickSight. If you’re using the Standard Edition, you can easily upgrade your subscription. For more information about the different editions, see Amazon QuickSight Pricing.

  1. You need the QuickSight Enterprise Edition to complete the following steps. For more information, see How do I create an Amazon QuickSight Enterprise edition account?
  2. After you log in to QuickSight, select the same Region that you launched Amazon SageMaker.
  3. Choose Manage QuickSight.
    Visualizing Amazon SageMaker machine learning predictions with Amazon QuickSight 2
  4. Choose Security & permissions.
  5. Choose Add or remove.
    Visualizing Amazon SageMaker machine learning predictions with Amazon QuickSight 3
  6. Select Amazon S3.
  7. Choose Select S3 buckets.
    Visualizing Amazon SageMaker machine learning predictions with Amazon QuickSight 4
  8. Select the bucket you created.
    Visualizing Amazon SageMaker machine learning predictions with Amazon QuickSight 5
  9. Select Amazon SageMaker.
  10. Choose Update.
    Visualizing Amazon SageMaker machine learning predictions with Amazon QuickSight 6Completing these steps requires administrator privileges.
  11. To return to the QuickSight console, choose the QuickSight

 

Setting up the dataset in QuickSight and pulling in the churn prediction

A test dataset already uploaded into your bucket when you ran the notebook. It should be in S3://<bucket_name>/<prefix>/rawtest/test.csv.  This file has customer details in the same format as the training dataset you used earlier in Amazon SageMaker, with the exception of the label column (Churn). You use this test set for prediction. You can get the <bucket_name> and <prefix> from the first cell of the notebook.

  1. On the QuickSight console, choose Manage Data.
  2. Choose New Dataset.
  3. Choose S3.
    Visualizing Amazon SageMaker machine learning predictions with Amazon QuickSight 7
  4. Using a text editor, create a manifest file (e.g. manifest.json) on local with the following content (replace <bucket_name> and <prefix> with what you have set before in the notebook):
    {
        "fileLocations": [
            {
                "URIPrefixes": [
                    "s3://<bucket-name>/<prefix>/rawtest/"
                ]
            }
        ],
        "globalUploadSettings": {
            "format": "CSV",
            "delimiter": ",",
            "textqualifier": """,
            "containsHeader": "true"
        }
    }

  5. Upload this file to create the Amazon S3 data source.
    Visualizing Amazon SageMaker machine learning predictions with Amazon QuickSight 8
  6. Choose Edit/Preview data.
    Visualizing Amazon SageMaker machine learning predictions with Amazon QuickSight 9
  7. To augment your data with the Amazon SageMaker model you built earlier, choose Augment with SageMaker.
    Visualizing Amazon SageMaker machine learning predictions with Amazon QuickSight 10
  8. For Model, choose the notebook you created (with the custom name that starts with QS-inference-pipeline-).Before you use an Amazon SageMaker model with QuickSight data, you have to create a JSON schema file that contains the metadata that QuickSight needs to process the model. It provides metadata about the fields, data types, column order, output, and settings that the model expects, such as type of the instance to use for generating the predictions.
  9. Download the schema file for this post from the GitHub repo.
  10. Save the file Churn_schema.json to local.
  11. For Schema, upload your file.
    Visualizing Amazon SageMaker machine learning predictions with Amazon QuickSight 11
  12. Choose Next.You’re now on the Review inputs page, which shows how each field in the provided schema is mapped to your dataset’s fields. These fields are what you model expects as inputs for inference. If any fields aren’t mapped correctly, change them from the drop-down menus.
  13. Choose Next.
    Visualizing Amazon SageMaker machine learning predictions with Amazon QuickSight 12
    You’re now on Review outputs page, which shows you the output of your model and the field name to add to your dataset as the output of the prediction. You can change the field name to a proper name that you want to show in your dataset.
  14. Choose Prepare data.
    Visualizing Amazon SageMaker machine learning predictions with Amazon QuickSight 13
  15. Read and close the info message.
  16. Choose Save & Visualize.
    Visualizing Amazon SageMaker machine learning predictions with Amazon QuickSight 14

This starts a job in SageMaker to run the inference and adds a new column to your dataset. It can take approximately 4 minutes for the Amazon SageMaker model to run a batch transform job to complete the inference and load the full scored dataset with the Churn column into SPICE.

SPICE is the in-memory optimized calculation engine for QuickSight, designed specifically for fast, one-time data visualization. SPICE is engineered to rapidly perform advanced calculations and serve data. You can save time with SPICE because you don’t need to retrieve the data every time you change an analysis or update a visual.

When the Amazon SageMaker inference is complete, you see an Import complete message.

Visualizing Amazon SageMaker machine learning predictions with Amazon QuickSight 15

Creating a dashboard with churn predictions

You can now use the prediction output to build a dashboard and visualize the results. The following screenshot shows the final dashboard you achieve with this walkthrough.

Visualizing Amazon SageMaker machine learning predictions with Amazon QuickSight 16

Plotting customers likely to churn

Start by building a donut chart to plot customers likely churn.

  1. Under Fields list, choose Churn.
    Because the Visual types uses Auto Graph by default, QuickSight determines that a bar chart is best suited to represent this data and gives you the split between true and false predictions.
    Visualizing Amazon SageMaker machine learning predictions with Amazon QuickSight 17
  2. To see this as a donut chart, under Visual types, choose the donut icon.
  3. To change the title, choose the title field and enter Customers likely to churn.
    Visualizing Amazon SageMaker machine learning predictions with Amazon QuickSight 18
  4. To hide the legend, choose the Visual drop-down menu and choose Hide legend.
    Visualizing Amazon SageMaker machine learning predictions with Amazon QuickSight 19

Visualizing potential revenue loss due to churn

You now add another visual showing how much revenue you stand to lose from customer churn.

  1. Choose Fields list and enter charge.
    Visualizing Amazon SageMaker machine learning predictions with Amazon QuickSight 20You see that charges are spread over four different columns.
    Visualizing Amazon SageMaker machine learning predictions with Amazon QuickSight 21You can create a calculated field that adds up these four columns.
  2. Choose Add.
  3. Choose Add calculated field.
    Visualizing Amazon SageMaker machine learning predictions with Amazon QuickSight 22
  4. For Calculated field name, enter Call Charges.
  5. For Formula, choose the following fields:
    1. Day Charge
    2. Eve Charge
    3. Intl Charge
    4. Night Charge
  6. Choose Create.
    Visualizing Amazon SageMaker machine learning predictions with Amazon QuickSight 23
  7. Choose Add.
  8. Choose Add visual.
    Visualizing Amazon SageMaker machine learning predictions with Amazon QuickSight 24
  9. Under Fields list, choose Call Charges.You can now see the total call charges across all customers.
    Visualizing Amazon SageMaker machine learning predictions with Amazon QuickSight 25
    You can also filter to show only charges for customers that are likely to churn.
  10. Choose Filter.
  11. Choose Create one.
  12. Choose Churn.
    Visualizing Amazon SageMaker machine learning predictions with Amazon QuickSight 26
  13. Choose the filter to expand it.
    Visualizing Amazon SageMaker machine learning predictions with Amazon QuickSight 27
  14. Select True.
  15. Choose Apply.
    Visualizing Amazon SageMaker machine learning predictions with Amazon QuickSight 28
    You can now see charges that you stand to lose due to customer churn.
  16. Choose the visual title and enter the name Predicted loss of charges.
    Visualizing Amazon SageMaker machine learning predictions with Amazon QuickSight 29

Visualizing churn by state

You can also visualize the number of churns by state.

  1. Choose Add.
  2. Choose Add visual.
  3. Under Fields list, choose State and Churn.
  4. Under Visual types, choose the horizontal stacked bar.
  5. Hide the legend.
  6. Change the title to Churn by State.
    Visualizing Amazon SageMaker machine learning predictions with Amazon QuickSight 30

Details for churn analysis

This final visual combines many details for churn analysis.

  1. Choose Add.
  2. Choose Add visual.
  3. Under Fields list, choose State, Area code, Phone, Account Length, CustServ Calls, Call Charges, and Churn.
  4. Under Visual types, choose the table icon.
  5. Change the name to Details for churn analysis.
    Visualizing Amazon SageMaker machine learning predictions with Amazon QuickSight 31

Customizing the dashboard display

The following section shows how to improve the look of your dashboard. You can first add a title.

  1. Choose Add.
  2. Choose Add title.
    Visualizing Amazon SageMaker machine learning predictions with Amazon QuickSight 32
  3. Choose Sheet title and enter Customer Churn Analysis.
    Visualizing Amazon SageMaker machine learning predictions with Amazon QuickSight 33
    Next, resize the visuals to make three of them fit on the top row.
  4. To resize, choose the bottom right corner handle.
  5. To move the visual around, choose the top center handle.
    Visualizing Amazon SageMaker machine learning predictions with Amazon QuickSight 34
  6. To change the theme, choose Themes.
  7. Choose Starter themes.
  8. Choose Midnight.
  9. Choose Apply.
    Visualizing Amazon SageMaker machine learning predictions with Amazon QuickSight 35

You have completed the design process and are ready to publish the dashboard.

Visualizing Amazon SageMaker machine learning predictions with Amazon QuickSight 36

Publishing the dashboard

To publish your dashboard, complete the following steps:

  1. Choose Share.
  2. Choose Publish dashboard.
    Visualizing Amazon SageMaker machine learning predictions with Amazon QuickSight 37
  3. For Publish new dashboard as, enter a name for your dashboard.
  4. Choose Publish dashboard.
    Visualizing Amazon SageMaker machine learning predictions with Amazon QuickSight 38

You now have the dashboard you set out to build.

Visualizing Amazon SageMaker machine learning predictions with Amazon QuickSight 39

Conclusion

QuickSight and Amazon SageMaker make it faster, easier, and more cost-effective for you to use your ML models for visualization and predictions. This post demonstrated how to integrate QuickSight with Amazon Sagemaker to automate the entire data movement and inference pipeline, without having to write a single line of code. This solution reduces the time it takes to get predictions from your company’s pre-built models. In addition, the approach is very cost-effective because you only pay for the hourly instance usage of the SageMaker batch transform job when the inference is running, without requiring SageMaker endpoints to run even when not in use.

Give the model inference feature of QuickSight a try, and share your feedback and questions in the comments.


About the Authors

Visualizing Amazon SageMaker machine learning predictions with Amazon QuickSight 40Saeed Aghabozorgi Ph.D. is senior ML Specialist in AWS, with a track record of developing enterprise level solutions that substantially increase customers’ ability to turn their data into actionable knowledge. He is also a researcher in the artificial intelligence and machine learning field.

 

 

 

 

Visualizing Amazon SageMaker machine learning predictions with Amazon QuickSight 41Raj Patel is a Software Development Manager at AWS QuickSight. He leads the Machine Learning (ML) Insights team, building features that use ML to solve business problems. Outside work, he enjoys hiking, watching sports and spending time with his 2 kids.

 

 

 

Visualizing Amazon SageMaker machine learning predictions with Amazon QuickSight 42Luis Wang is a principal product manager for Amazon QuickSight. He’s been with AWS for over 6 years, working on various services including Amazon EC2 and then launching Amazon QuickSight. Luis is now focused on the application of machine learning and AI to business intelligence and analytics at QuickSight. He enjoys running, watching sitcoms and spending time with his family.

 

 

 

Visualizing Amazon SageMaker machine learning predictions with Amazon QuickSight 43Arun Santhosh is a Specialized Global Solution Architect for Amazon QuickSight.

 

 



Read More

LEAVE A REPLY

Please enter your comment!
Please enter your name here