Reader small image

You're reading from  Serverless Machine Learning with Amazon Redshift ML

Product typeBook
Published inAug 2023
Reading LevelBeginner
PublisherPackt
ISBN-139781804619285
Edition1st Edition
Languages
Right arrow
Authors (4):
Debu Panda
Debu Panda
author image
Debu Panda

Debu Panda, a Senior Manager, Product Management at AWS, is an industry leader in analytics, application platform, and database technologies, and has more than 25 years of experience in the IT world. Debu has published numerous articles on analytics, enterprise Java, and databases and has presented at multiple conferences such as re:Invent, Oracle Open World, and Java One. He is lead author of the EJB 3 in Action (Manning Publications 2007, 2014) and Middleware Management (Packt, 2009).
Read more about Debu Panda

Phil Bates
Phil Bates
author image
Phil Bates

Phil Bates is a Senior Analytics Specialist Solutions Architect at AWS. He has more than 25 years of experience implementing large-scale data warehouse solutions. He is passionate about helping customers through their cloud journey and leveraging the power of ML within their data warehouse.
Read more about Phil Bates

Bhanu Pittampally
Bhanu Pittampally
author image
Bhanu Pittampally

Bhanu Pittampally is Analytics Specialist Solutions Architect at Amazon Web Services. His background is in data and analytics and is in the field for over 16 years. He currently lives in Frisco, TX with his wife Kavitha and daughters Vibha and Medha.
Read more about Bhanu Pittampally

Sumeet Joshi
Sumeet Joshi
author image
Sumeet Joshi

Sumeet Joshi is an Analytics Specialist Solutions Architect based out of New York. He specializes in building large-scale data warehousing solutions. He has over 17 years of experience in the data warehousing and analytical space.
Read more about Sumeet Joshi

View More author details
Right arrow

Deep Learning with Redshift ML

We explored supervised learning in Chapters 6 and 7 and unsupervised learning models in Chapter 8. In this chapter, we will explore deep learning algorithms, a multilayer perceptron (MLP), which is a feedforward artificial neural network (ANN), and understand how it handles data that is not linearly separable (which means the data points in your data cannot be separated by a clear line). This chapter will provide detailed steps on how to perform deep learning in Amazon Redshift ML using MLP. By the end of this chapter, you will be in a position to identify a business problem that can be solved using MLP and know how to create the model, evaluate the performance of the model, and run predictions.

In this chapter, we will go through the following main topics:

  • Introduction to deep learning
  • Business problem
  • Uploading and analyzing the data
  • Creating a multiclass classification model using MLP
  • Running predictions

Technical requirements

This chapter requires a web browser and access to the following:

  • AWS account
  • Amazon Redshift Serverless endpoint
  • Amazon Redshift Query Editor v2

You can find the code used in this chapter here: https://github.com/PacktPublishing/Serverless-Machine-Learning-with-Amazon-Redshift/blob/main/CodeFiles/chapter9/chapter9.sql.

Introduction to deep learning

Deep learning is a type of artificial intelligence (AI) that uses algorithms to analyze and learn data to draw output similar to the way humans do. Deep learning can leverage both supervised and unsupervised learning using artificial neural networks (ANNs). In deep learning, a set of outputs is generated from the input layers using a feedforward ANN called an MLP. The MLP utilizes backpropagation to feed the errors from the outputs back into the layers to compute one layer at a time and iterates until the model has learned the patterns and relationships in the input data to arrive at a specific output.

Feature learning is a set of techniques where the machine uses raw data to derive the characteristics of a class in the data to derive a specific task at hand. Deep learning models use feature learning efficiently to learn complex, redundant, and variable input data and classify the specified task. Thus, it eliminates the need for manual feature engineering...

Business problem

We will use a wall-following robot navigation dataset to build a machine learning model using the MLP algorithm. The robot is equipped with ultrasound sensors and data is collected as the robot navigates through the room in a clockwise direction. The goal here is to guide the robot to follow the wall by giving simple directions such as Move-Forward, Slight-Right-Turn, Sharp-Right-Turn, and Slight-Left-Turn.

Since there are classes to predict for a given set of sensor readings, this is going to be a multiclass problem. We will use MLP to correctly guide the robot to follow the wall. (This data is taken from https://archive.ics.uci.edu/ml/datasets/Wall-Following+Robot+Navigation+Data and is attributed to Ananda Freire, Marcus Veloso, and Guilherme Barreto (2019). UCI Machine Learning Repository [http://archive.ics.uci.edu/ml]. Irvine, CA: University of California, School of Information and Computer Science.)

Please follow the detailed document on the page to gain...

Creating a multiclass classification model using MLP

In this exercise, we are going to guide the CREATE MODEL statement to use the MLP model. You will achieve that by setting the model_type parameter to MLP. The rest of the parameters can be set to default.

Let’s create a model to predict the direction of the robot:

CREATE MODEL chapter9_deeplearning.predict_robot_direction
from  (select
us1 ,us2 , us3 , us4 , us5 , us6 ,us7 , us8 , us9 ,
us10 ,us11 ,us12 ,us13 ,us14 ,us15 ,us16 ,us17 ,
us18 ,us19 ,us20 ,us21 , us22 ,us23 ,us24 , direction
  from chapter9_deeplearning.robot_navigation
  where mod(id,5) !=0)
target direction
function predict_robot_direction_fn
iam_role default
model_type mlp
settings (s3_bucket 'replace-with-your-s3-bucket',
max_runtime 1800);

The CREATE MODEL function is run with a max_runtime value of 1800 seconds. This means the maximum amount of time to train the model is 30 minutes. Training jobs often complete...

Summary

In this chapter, we discussed deep learning models and why you need them and showed you how to create an MLP model on sensor-reading data to predict the next movement of the robot. You learned that non-linear datasets are suited for deep learning and created a multiclass classification model using the MLP algorithm.

In the next chapter, we will show you how to create a model with complete control of hyper-tuning parameters using XGBoost algorithms.

lock icon
The rest of the chapter is locked
You have been reading a chapter from
Serverless Machine Learning with Amazon Redshift ML
Published in: Aug 2023Publisher: PacktISBN-13: 9781804619285
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime

Authors (4)

author image
Debu Panda

Debu Panda, a Senior Manager, Product Management at AWS, is an industry leader in analytics, application platform, and database technologies, and has more than 25 years of experience in the IT world. Debu has published numerous articles on analytics, enterprise Java, and databases and has presented at multiple conferences such as re:Invent, Oracle Open World, and Java One. He is lead author of the EJB 3 in Action (Manning Publications 2007, 2014) and Middleware Management (Packt, 2009).
Read more about Debu Panda

author image
Phil Bates

Phil Bates is a Senior Analytics Specialist Solutions Architect at AWS. He has more than 25 years of experience implementing large-scale data warehouse solutions. He is passionate about helping customers through their cloud journey and leveraging the power of ML within their data warehouse.
Read more about Phil Bates

author image
Bhanu Pittampally

Bhanu Pittampally is Analytics Specialist Solutions Architect at Amazon Web Services. His background is in data and analytics and is in the field for over 16 years. He currently lives in Frisco, TX with his wife Kavitha and daughters Vibha and Medha.
Read more about Bhanu Pittampally

author image
Sumeet Joshi

Sumeet Joshi is an Analytics Specialist Solutions Architect based out of New York. He specializes in building large-scale data warehousing solutions. He has over 17 years of experience in the data warehousing and analytical space.
Read more about Sumeet Joshi