Machine Learning Engineering on AWS

Book description

Work seamlessly with production-ready machine learning systems and pipelines on AWS by addressing key pain points encountered in the ML life cycle

Key Features

  • Gain practical knowledge of managing ML workloads on AWS using Amazon SageMaker, Amazon EKS, and more
  • Use container and serverless services to solve a variety of ML engineering requirements
  • Design, build, and secure automated MLOps pipelines and workflows on AWS

Book Description

There is a growing need for professionals with experience in working on machine learning (ML) engineering requirements as well as those with knowledge of automating complex MLOps pipelines in the cloud. This book explores a variety of AWS services, such as Amazon Elastic Kubernetes Service, AWS Glue, AWS Lambda, Amazon Redshift, and AWS Lake Formation, which ML practitioners can leverage to meet various data engineering and ML engineering requirements in production.

This machine learning book covers the essential concepts as well as step-by-step instructions that are designed to help you get a solid understanding of how to manage and secure ML workloads in the cloud. As you progress through the chapters, you'll discover how to use several container and serverless solutions when training and deploying TensorFlow and PyTorch deep learning models on AWS. You'll also delve into proven cost optimization techniques as well as data privacy and model privacy preservation strategies in detail as you explore best practices when using each AWS.

By the end of this AWS book, you'll be able to build, scale, and secure your own ML systems and pipelines, which will give you the experience and confidence needed to architect custom solutions using a variety of AWS services for ML engineering requirements.

What you will learn

  • Find out how to train and deploy TensorFlow and PyTorch models on AWS
  • Use containers and serverless services for ML engineering requirements
  • Discover how to set up a serverless data warehouse and data lake on AWS
  • Build automated end-to-end MLOps pipelines using a variety of services
  • Use AWS Glue DataBrew and SageMaker Data Wrangler for data engineering
  • Explore different solutions for deploying deep learning models on AWS
  • Apply cost optimization techniques to ML environments and systems
  • Preserve data privacy and model privacy using a variety of techniques

Who this book is for

This book is for machine learning engineers, data scientists, and AWS cloud engineers interested in working on production data engineering, machine learning engineering, and MLOps requirements using a variety of AWS services such as Amazon EC2, Amazon Elastic Kubernetes Service (EKS), Amazon SageMaker, AWS Glue, Amazon Redshift, AWS Lake Formation, and AWS Lambda -- all you need is an AWS account to get started. Prior knowledge of AWS, machine learning, and the Python programming language will help you to grasp the concepts covered in this book more effectively.

Table of contents

  1. Machine Learning Engineering on AWS
  2. Copyright © 2022 Packt Publishing
  3. Contributors
  4. About the author
  5. About the reviewers
  6. Preface
    1. Who this book is for
    2. What this book covers
    3. To get the most out of this book
    4. Download the example code files
    5. Download the color images
    6. Conventions used
    7. Get in touch
    8. Share Your Thoughts
  7. Part 1: Getting Started with Machine Learning Engineering on AWS
  8. Chapter 1: Introduction to ML Engineering on AWS
    1. Technical requirements
    2. What is expected from ML engineers?
    3. How ML engineers can get the most out of AWS
    4. Essential prerequisites
      1. Creating the Cloud9 environment
      2. Increasing Cloud9’s storage
      3. Installing the Python prerequisites
    5. Preparing the dataset
      1. Generating a synthetic dataset using a deep learning model
      2. Exploratory data analysis
      3. Train-test split
      4. Uploading the dataset to Amazon S3
    6. AutoML with AutoGluon
      1. Setting up and installing AutoGluon
      2. Performing your first AutoGluon AutoML experiment
    7. Getting started with SageMaker and SageMaker Studio
      1. Onboarding with SageMaker Studio
      2. Adding a user to an existing SageMaker Domain
    8. No-code machine learning with SageMaker Canvas
    9. AutoML with SageMaker Autopilot
    10. Summary
    11. Further reading
  9. Chapter 2: Deep Learning AMIs
    1. Technical requirements
    2. Getting started with Deep Learning AMIs
    3. Launching an EC2 instance using a Deep Learning AMI
      1. Locating the framework-specific DLAMI
      2. Choosing the instance type
      3. Ensuring a default secure configuration
      4. Launching the instance and connecting to it using EC2 Instance Connect
    4. Downloading the sample dataset
    5. Training an ML model
    6. Loading and evaluating the model
    7. Cleaning up
    8. Understanding how AWS pricing works for EC2 instances
      1. Using multiple smaller instances to reduce the overall cost of running ML workloads
      2. Using spot instances to reduce the cost of running training jobs
    9. Summary
    10. Further reading
  10. Chapter 3: Deep Learning Containers
    1. Technical requirements
    2. Getting started with AWS Deep Learning Containers
    3. Essential prerequisites
      1. Preparing the Cloud9 environment
      2. Downloading the sample dataset
    4. Using AWS Deep Learning Containers to train an ML model
    5. Serverless ML deployment with Lambda’s container image support
      1. Building the custom container image
      2. Testing the container image
      3. Pushing the container image to Amazon ECR
      4. Running ML predictions on AWS Lambda
      5. Completing and testing the serverless API setup
    6. Summary
    7. Further reading
  11. Part 2:Solving Data Engineering and Analysis Requirements
  12. Chapter 4: Serverless Data Management on AWS
    1. Technical requirements
    2. Getting started with serverless data management
    3. Preparing the essential prerequisites
      1. Opening a text editor on your local machine
      2. Creating an IAM user
      3. Creating a new VPC
      4. Uploading the dataset to S3
    4. Running analytics at scale with Amazon Redshift Serverless
      1. Setting up a Redshift Serverless endpoint
      2. Opening Redshift query editor v2
      3. Creating a table
      4. Loading data from S3
      5. Querying the database
      6. Unloading data to S3
    5. Setting up Lake Formation
      1. Creating a database
      2. Creating a table using an AWS Glue Crawler
    6. Using Amazon Athena to query data in Amazon S3
      1. Setting up the query result location
      2. Running SQL queries using Athena
    7. Summary
    8. Further reading
  13. Chapter 5: Pragmatic Data Processing and Analysis
    1. Technical requirements
    2. Getting started with data processing and analysis
    3. Preparing the essential prerequisites
      1. Downloading the Parquet file
      2. Preparing the S3 bucket
    4. Automating data preparation and analysis with AWS Glue DataBrew
      1. Creating a new dataset
      2. Creating and running a profile job
      3. Creating a project and configuring a recipe
      4. Creating and running a recipe job
      5. Verifying the results
    5. Preparing ML data with Amazon SageMaker Data Wrangler
      1. Accessing Data Wrangler
      2. Importing data
      3. Transforming the data
      4. Analyzing the data
      5. Exporting the data flow
      6. Turning off the resources
      7. Verifying the results
    6. Summary
    7. Further reading
  14. Part 3: Diving Deeper with Relevant Model Training and Deployment Solutions
  15. Chapter 6: SageMaker Training and Debugging Solutions
    1. Technical requirements
    2. Getting started with the SageMaker Python SDK
    3. Preparing the essential prerequisites
      1. Creating a service limit increase request
    4. Training an image classification model with the SageMaker Python SDK
      1. Creating a new Notebook in SageMaker Studio
      2. Downloading the training, validation, and test datasets
      3. Uploading the data to S3
      4. Using the SageMaker Python SDK to train an ML model
      5. Using the %store magic to store data
      6. Using the SageMaker Python SDK to deploy an ML model
    5. Using the Debugger Insights Dashboard
    6. Utilizing Managed Spot Training and Checkpoints
    7. Cleaning up
    8. Summary
    9. Further reading
  16. Chapter 7: SageMaker Deployment Solutions
    1. Technical requirements
    2. Getting started with model deployments in SageMaker
    3. Preparing the pre-trained model artifacts
    4. Preparing the SageMaker script mode prerequisites
      1. Preparing the inference.py file
      2. Preparing the requirements.txt file
      3. Preparing the setup.py file
    5. Deploying a pre-trained model to a real-time inference endpoint
    6. Deploying a pre-trained model to a serverless inference endpoint
    7. Deploying a pre-trained model to an asynchronous inference endpoint
      1. Creating the input JSON file
      2. Adding an artificial delay to the inference script
      3. Deploying and testing an asynchronous inference endpoint
    8. Cleaning up
    9. Deployment strategies and best practices
    10. Summary
    11. Further reading
  17. Part 4:Securing, Monitoring, and Managing Machine Learning Systems and Environments
  18. Chapter 8: Model Monitoring and Management Solutions
    1. Technical prerequisites
    2. Registering models to SageMaker Model Registry
      1. Creating a new notebook in SageMaker Studio
      2. Registering models to SageMaker Model Registry using the boto3 library
    3. Deploying models from SageMaker Model Registry
    4. Enabling data capture and simulating predictions
    5. Scheduled monitoring with SageMaker Model Monitor
    6. Analyzing the captured data
    7. Deleting an endpoint with a monitoring schedule
    8. Cleaning up
    9. Summary
    10. Further reading
  19. Chapter 9: Security, Governance, and Compliance Strategies
    1. Managing the security and compliance of ML environments
      1. Authentication and authorization
      2. Network security
      3. Encryption at rest and in transit
      4. Managing compliance reports
      5. Vulnerability management
    2. Preserving data privacy and model privacy
      1. Federated Learning
      2. Differential Privacy
      3. Privacy-preserving machine learning
      4. Other solutions and options
    3. Establishing ML governance
      1. Lineage Tracking and reproducibility
      2. Model inventory
      3. Model validation
      4. ML explainability
      5. Bias detection
      6. Model monitoring
      7. Traceability, observability, and auditing
      8. Data quality analysis and reporting
      9. Data integrity management
    4. Summary
    5. Further reading
  20. Part 5:Designing and Building End-to-end MLOps Pipelines
  21. Chapter 10: Machine Learning Pipelines with Kubeflow on Amazon EKS
    1. Technical requirements
    2. Diving deeper into Kubeflow, Kubernetes, and EKS
    3. Preparing the essential prerequisites
      1. Preparing the IAM role for the EC2 instance of the Cloud9 environment
      2. Attaching the IAM role to the EC2 instance of the Cloud9 environment
      3. Updating the Cloud9 environment with the essential prerequisites
    4. Setting up Kubeflow on Amazon EKS
    5. Running our first Kubeflow pipeline
    6. Using the Kubeflow Pipelines SDK to build ML workflows
    7. Cleaning up
    8. Recommended strategies and best practices
    9. Summary
    10. Further reading
  22. Chapter 11: Machine Learning Pipelines with SageMaker Pipelines
    1. Technical requirements
    2. Diving deeper into SageMaker Pipelines
    3. Preparing the essential prerequisites
    4. Running our first pipeline with SageMaker Pipelines
      1. Defining and preparing our first ML pipeline
      2. Running our first ML pipeline
    5. Creating Lambda functions for deployment
      1. Preparing the Lambda function for deploying a model to a new endpoint
      2. Preparing the Lambda function for checking whether an endpoint exists
      3. Preparing the Lambda function for deploying a model to an existing endpoint
    6. Testing our ML inference endpoint
    7. Completing the end-to-end ML pipeline
      1. Defining and preparing the complete ML pipeline
      2. Running the complete ML pipeline
    8. Cleaning up
    9. Recommended strategies and best practices
    10. Summary
    11. Further reading
  23. Index
    1. Why subscribe?
  24. Other Books You May Enjoy
    1. Packt is searching for authors like you
    2. Share Your Thoughts

Product information

  • Title: Machine Learning Engineering on AWS
  • Author(s): Joshua Arvin Lat
  • Release date: October 2022
  • Publisher(s): Packt Publishing
  • ISBN: 9781803247595