Book Image

Mastering Machine Learning on AWS

By : Dr. Saket S.R. Mengle, Maximo Gurmendez
Book Image

Mastering Machine Learning on AWS

By: Dr. Saket S.R. Mengle, Maximo Gurmendez

Overview of this book

Amazon Web Services (AWS) is constantly driving new innovations that empower data scientists to explore a variety of machine learning (ML) cloud services. This book is your comprehensive reference for learning and implementing advanced ML algorithms in AWS cloud. As you go through the chapters, you’ll gain insights into how these algorithms can be trained, tuned, and deployed in AWS using Apache Spark on Elastic Map Reduce (EMR), SageMaker, and TensorFlow. While you focus on algorithms such as XGBoost, linear models, factorization machines, and deep nets, the book will also provide you with an overview of AWS as well as detailed practical applications that will help you solve real-world problems. Every application includes a series of companion notebooks with all the necessary code to run on AWS. In the next few chapters, you will learn to use SageMaker and EMR Notebooks to perform a range of tasks, right from smart analytics and predictive modeling through to sentiment analysis. By the end of this book, you will be equipped with the skills you need to effectively handle machine learning projects and implement and evaluate algorithms on AWS.
Table of Contents (24 chapters)
Free Chapter
1
Section 1: Machine Learning on AWS
3
Section 2: Implementing Machine Learning Algorithms at Scale on AWS
9
Section 3: Deep Learning
13
Section 4: Integrating Ready-Made AWS Machine Learning Services
17
Section 5: Optimizing and Deploying Models through AWS
Appendix: Getting Started with AWS

Hyperparameter tuning in SageMaker

As we mentioned in the Automatic hyperparameter tuning section, SageMaker has a library for smart parameter tuning using Bayesian optimization. In this section, we will demonstrate how we can further tune the model we created in Chapter 4, Predicting User Behavior with Tree-Based Methods. Recall from that chapter that we posed a binary classification problem for trying to predict whether a user would click on an advertisement. We used an xgboost model, but at that point, we hadn't performed any parameter tuning.

We will start by creating the SageMaker session and choosing xgboost:

import boto3
import sagemaker
from sagemaker import get_execution_role

sess = sagemaker.Session()
role = get_execution_role()
container = sagemaker.amazon.amazon_estimator.get_image_uri('us-east-1', "xgboost", "latest")

s3_validation_data...