Open In Colab

Lesson 1 AWS Machine Learning-Specialty (ML-S) Certification

Watch Lesson 1: AWS Machine Learning-Speciality (MLS) Video

Pragmatic AI Labs

alt text

This notebook was produced by Pragmatic AI Labs. You can continue learning about these topics by:

1.1 Certification Overview

Watch 1.1 Certification Overview Video Lesson

Load AWS API Keys

Put keys in local or remote GDrive:

cp ~/.aws/credentials /Users/myname/Google\ Drive/awsml/

Mount GDrive

from google.colab import drive
drive.mount('/content/gdrive')
Drive already mounted at /content/gdrive; to attempt to forcibly remount, call drive.mount("/content/gdrive", force_remount=True).

import os;os.listdir("/content/gdrive/My Drive/awsml")
['kaggle.json', 'credentials', 'config']

Install Boto

!pip -q install boto3

Create API Config

!mkdir -p ~/.aws &&\
  cp /content/gdrive/My\ Drive/awsml/credentials ~/.aws/credentials 

Test Comprehend API Call

import boto3
comprehend = boto3.client(service_name='comprehend', region_name="us-east-1")
text = "There is smoke in San Francisco"
comprehend.detect_sentiment(Text=text, LanguageCode='en')
{'ResponseMetadata': {'HTTPHeaders': {'connection': 'keep-alive',
   'content-length': '160',
   'content-type': 'application/x-amz-json-1.1',
   'date': 'Tue, 11 Dec 2018 01:07:46 GMT',
   'x-amzn-requestid': '2b726af9-fce1-11e8-a4e1-2d227516436e'},
  'HTTPStatusCode': 200,
  'RequestId': '2b726af9-fce1-11e8-a4e1-2d227516436e',
  'RetryAttempts': 0},
 'Sentiment': 'NEUTRAL',
 'SentimentScore': {'Mixed': 0.008628507144749165,
  'Negative': 0.1037612184882164,
  'Neutral': 0.8582549691200256,
  'Positive': 0.0293553676456213}}

Audience

Intended for individuals who perform Development or Data Science role

Validates ability to:

  • “design, implement, deploy and maintain ML solutions”
  • “select and justify appropriate ML approaches”
  • “indentify appropriate AWS services to implement ML solutions”
  • “Design and implement scalable, cost-optimized, reliable, and secure ML solutions”
  • Hands-on experience:

  • developing
  • architecting
  • running ML/deep learning workloads on AWS Cloud

  • Ability to express intuition behind basic ML algorithms
  • Experience performance basic hyperparameter optimization
  • Experience with ML and deep learning frameworks
  • Ability to follow model training best practices
  • Ability to follow deployment and operational best practices

1.2 Exam Study Resources

Watch 1.2 Exam Study Resources Video Lesson

Official AWS Material

Sequential Split

1.3 Review Exam Guide

Watch 1.3 Review Exam Guide Video Lesson

AWS Certified Machine Learning–Specialty (MLS-C01) Exam Guide

Domains Covered

Data Engineering

  • Create data repositories for Machine Learning
  • Identify and implement a data-ingestion solution
  • Identify and implement a data-transformation solution

Exploratory Data Analysis

  • Sanitize and prepare data modeling
  • Perform feature engineering
  • Analyze and visualize data for machine learning

Modeling

  • Frame business problems as machine learning problems
  • Select the appropriate model(s) for a given machine learning problem
  • Train machine learning models
  • Perform hyperparameter optimization
  • Evaluate machine learning models

Machine Learning Implementation and Operations

  • Build machine learning solutions for performance, availability, scalability, resiliency, and fault tolerance.
  • Recommend and implement the appropriate machine learning services and features for a given problem.
  • Apply basic AWS security practices to machine learning solutions.
  • Deploy and operationalize machine learning solutions.

1.4 Exam Strategy

Watch 1.4 Exam Strategy Video Lesson

Official Exam Study Guide

Study Path

1.5 Best Practices of ML on AWS

Watch 1.5 Best Practices of ML on AWS Video Lesson

Build vs Buy

hero

Overview

Auto and Managed ML Services on AWS

  • AWS Sagemaker
  • AWS Machine Learning

Human in the Loop

  • AWS Sagemaker Ground Truth
  • AWS Mechanical Turk

Supporting Technologies

  • MXNet

AWS Sagemaker

Sagemaker Features

AWS Sagemaker

  • Build

  • Preconfigured Jupyter Notebooks
  • Built in, High Performance Algorithms (Optimized petabyte-scale peformance)
  • Supports many frameworks: MXnet, Tensorflow, sklearn

  • Train

  • One click train with S3 target
  • Automatic hyperparameter tuning
  • Can scale training to clusters of machines with single line of code

  • Deploy

  • One click Deploy (creates HTTPS endpoint)
  • Automatic A/B Testing
  • Fully managed auto-scaling of inference

AWS Machine Learning

Amazon Machine Learning Service

alt text

Key Features

  • ” makes it easy for developers of all skill levels to use machine learning technology”
  • Managaged ML Service

Resources

MXNet

Open Source Docs

mxnet logo

  • Alternative to TensorFlow
  • Amazon Backed
  • Integrated into Sagemaker and DeepLense
  • Has production-ready orchestration tools: ECS, Docker, Kubernetes
  • Can do inference via AWS Lambda

Resources

Demo AWS Sagemaker

Demo AWS ML Service

Build vs Buy

  • When to use AI APIs vs ML Platforms

1.6 Techniques to accelerate hands-on practice

Watch 1.6 Techniques to accelerate hands-on practice Video Lesson

Using Interactive QWIKLABS

A temporary, but real AWS environment that teaches specific labs.

QWiklabs

Big Data on AWS

Big Data on AWS Quest

Intro to Machine Learning

Introduction to Machine Learning

Using AWS Console, Sagemaker and APIS

  • Console to Explore
  • Sagemaker
  • APIs via Boto

Watch 1.7 Understand important ML related services Video Lesson

ML Platform Services

Amazon Sagemaker

[Demo] Overview Console

AWS DeepLens

alt text

[Demo] Overview Console

EMR

  • Amazon EMR
  • Managed Hadoop/Spark
  • Use cases:

    • clickstream analysis
    • real-time analytics
    • log analysis
    • ETL
    • predictive analytics
    • genomics

[Demo] Overview Console

Amazon Machine Learning Service

[Demo] Overview Console

Deep Learning on AWS

AWS Deep Learning AMIs

Apache MXNet

TensorFlow on AWS

AI APIs

Vision Services

Rekognition Image
  • Deep learning-based image analysis
Rekognition Video
  • Deep learning-based video analysis

Conversational chatbots

Amazon Lex
  • Amazon Lex
  • Service for building conversational interfaces

Language Services

Comprehend

Neutral Sentiment

import boto3
comprehend = boto3.client(service_name='comprehend', region_name="us-east-1")
text = "There is smoke in San Francisco"
comprehend.detect_sentiment(Text=text, LanguageCode='en')
{'ResponseMetadata': {'HTTPHeaders': {'connection': 'keep-alive',
   'content-length': '160',
   'content-type': 'application/x-amz-json-1.1',
   'date': 'Tue, 11 Dec 2018 01:07:59 GMT',
   'x-amzn-requestid': '3368fdfa-fce1-11e8-8656-5735cedac40a'},
  'HTTPStatusCode': 200,
  'RequestId': '3368fdfa-fce1-11e8-8656-5735cedac40a',
  'RetryAttempts': 0},
 'Sentiment': 'NEUTRAL',
 'SentimentScore': {'Mixed': 0.008628507144749165,
  'Negative': 0.1037612184882164,
  'Neutral': 0.8582549691200256,
  'Positive': 0.0293553676456213}}

Negative Sentiment

import boto3
comprehend = boto3.client(service_name='comprehend', region_name="us-east-1")
text = "There is smoke in San Francisco and it makes me very angry"
comprehend.detect_sentiment(Text=text, LanguageCode='en')
{'ResponseMetadata': {'HTTPHeaders': {'connection': 'keep-alive',
   'content-length': '164',
   'content-type': 'application/x-amz-json-1.1',
   'date': 'Tue, 11 Dec 2018 01:08:17 GMT',
   'x-amzn-requestid': '3e127c6f-fce1-11e8-b936-d1be599a3739'},
  'HTTPStatusCode': 200,
  'RequestId': '3e127c6f-fce1-11e8-b936-d1be599a3739',
  'RetryAttempts': 0},
 'Sentiment': 'NEGATIVE',
 'SentimentScore': {'Mixed': 0.00937745813280344,
  'Negative': 0.9539545774459839,
  'Neutral': 0.03619137033820152,
  'Positive': 0.00047663392615504563}}
trump_text = """
which it was not (but even if it was, it is only a CIVIL CASE, like Obama’s - but it was done correctly by a lawyer and there would not even be a fine. Lawyer’s liability if he made a mistake, not me). Cohen just trying to get his sentence reduced. WITCH HUNT!

"""
comprehend = boto3.client(service_name='comprehend', region_name="us-east-1")
comprehend.detect_sentiment(Text=trump_text,LanguageCode='en')

{'ResponseMetadata': {'HTTPHeaders': {'connection': 'keep-alive',
   'content-length': '160',
   'content-type': 'application/x-amz-json-1.1',
   'date': 'Tue, 11 Dec 2018 01:10:42 GMT',
   'x-amzn-requestid': '94b5be74-fce1-11e8-92e1-212d40a34fc0'},
  'HTTPStatusCode': 200,
  'RequestId': '94b5be74-fce1-11e8-92e1-212d40a34fc0',
  'RetryAttempts': 0},
 'Sentiment': 'NEGATIVE',
 'SentimentScore': {'Mixed': 0.0772324725985527,
  'Negative': 0.776195228099823,
  'Neutral': 0.10541720688343048,
  'Positive': 0.04115508496761322}}

Positive Sentiment

import boto3
comprehend = boto3.client(service_name='comprehend', region_name="us-east-1")
text = "There is no more smoke in San Francisco and it makes me very happy"
comprehend.detect_sentiment(Text=text, LanguageCode='en')
{'ResponseMetadata': {'HTTPHeaders': {'connection': 'keep-alive',
   'content-length': '163',
   'content-type': 'application/x-amz-json-1.1',
   'date': 'Mon, 10 Dec 2018 22:41:39 GMT',
   'x-amzn-requestid': 'c25e7c7c-fccc-11e8-b966-5f330c378b33'},
  'HTTPStatusCode': 200,
  'RequestId': 'c25e7c7c-fccc-11e8-b966-5f330c378b33',
  'RetryAttempts': 0},
 'Sentiment': 'POSITIVE',
 'SentimentScore': {'Mixed': 0.01339163538068533,
  'Negative': 0.007987627759575844,
  'Neutral': 0.04016350954771042,
  'Positive': 0.9384573101997375}}
Translate
import boto3
client = boto3.client('translate', region_name="us-east-1")
text = "Hola, mi nombre es Noah y me encanta el aprendizaje automático."
client.translate_text(Text=text,SourceLanguageCode="auto", TargetLanguageCode="en")

{'ResponseMetadata': {'HTTPHeaders': {'connection': 'keep-alive',
   'content-length': '124',
   'content-type': 'application/x-amz-json-1.1',
   'date': 'Tue, 11 Dec 2018 01:11:05 GMT',
   'x-amzn-requestid': 'a1dd350d-fce1-11e8-88f8-15e276ec8e51'},
  'HTTPStatusCode': 200,
  'RequestId': 'a1dd350d-fce1-11e8-88f8-15e276ec8e51',
  'RetryAttempts': 0},
 'SourceLanguageCode': 'es',
 'TargetLanguageCode': 'en',
 'TranslatedText': 'Hello, my name is Noah and I love machine learning.'}
Transcribe
import boto3
s3_path = "https://s3.amazonaws.com/pai-transcribe/transcribe-sample.dac1d22492611d998262c8c856b98a74180a1a8f.mp3"
Polly