AWS Machine Learning Foundations
Here are my notes from the a course on Machine Learning from the AWS Educate program.
Module 1 - Intro
Careers in ML
- Data Scientist - collecting an analyzing complex digital data, summarizing, correlating, etc.
- ML Engineer - Research, design and build ML models and systems
- Applied Science Engineer - Applying ML to a specific field of science
- ML Developer - Implement machine learning systems, training and retraining models
Module 2 - Introduction to Machine Learning Foundations
AI Overview
- AI - Programs that try to replicate human thinking (like playing chess against the computer)
- Machine Learning - Subset of AI where a program derives rules from data (data -> model -> prediction)
- Deep Learning - Subset of ML where a program learns dynamically based on continuous feedback
AI Terms
- Model - a trained algorithm that is used to identify patterns in your data
- Training Algorithm - The approach to training a model (more on that below)
- Computer Vision - image identification
- Artificial Neural Network - connected units (nodes) that are used to build an information model based on biological systems. Each node is an artificial nueron that receives input and produces an output
- Compute model instance - An EC2 that is designed for a specific area of AI
- Inference - using a trained model to make predictions or acheive tasks
Classification and Regression Problem Types (used in supervised learning)
- Binary Classifications - classifying some as true of false (ex. win/lose or fraudulent/not fraudulent)
- Multiclass Classifications - classifying something to fall within a category (hot, warm, cold)
- Regression - maps inputs to a continuous value (mapping on a line chart) (predicting a stock price)
Classical Programming vs ML
Use classical programming when you can define explicit rules for a task
Use machine learning when you need to define rules based on data sets, and the rules cannot be coded.
Algorithm Types
- Supervised learning - People provide data and label the data to train the model
- Uses classification and regression
- Unsupervised learning - The model finds patterns in the data without supervision from a human. The model itself labels the data. A subset of this type is clustering in which the model groups data in to clusters based on similarities.
- Reinforcement learning - The model improves itself based on feedback from previous iterations
Features and Weights
Features and weights are used in algorithms for training models.
Features are identified as important for accurate outcomes. For example it might be important to identify something as a hat, or not a hat. The model will use a 1 for yes and a 0 for no.
Weights can be applied to features. For example if a feature is more important in determining an accurate outcome, then it will have a higher weight.
Here's my attempt to demonstrate how features and weights work (based on the example in the course).
Step 1
- Is the item a 'hat' yes (1) or no (0)
- Apply the weight to this feature, for example if the item is a hat and the weight is 0.8.
Heres what the equation looks like, where x is the identity of the item and a is the weight:
f(x) = a * x
f(x) = 0.8 * 1
Step 2
- Is the item (which is a hat) of a particular brand, yes (1) or no (0)
- Apply the weight (assume that the weight is 0.25 and hat is of the particular brand and that the customer previously purchased 4 hats, one of which was of this particular brand. So we assign a weight of 0.25 to this feature (the brand)
Our equation then looks like this:
f(x) = a1*x1 + a2*x2
f(x) = 0.8*1 + 0.25*1
The final equation looks like this:
f(x) = 1.05
You might determine that if the final is greater than 1 then the model should recommend that the customer purchase the hat.
Module 3 - Machine Learning Pipeline
A series of steps that are used to solve a business problem.
- Problem formulation
- Collect, clean, and label data
- Evaluate data
- Feature engineering - extracting more information from existing data to improve the model's predicting power
- Select and train a model (based on use case and business problem)
- Evaluate the model
- Tune model and return to feature engineer to repeat an iteration from there
- Does the model meet your business goals, if not return to feature engineering
Problem Formulation Identify a business problem that you believe can benefit from ML Articulate the problem and convert it into an ML problem.
- How is the task done today?
- How will success be measured?
- Do similar solutions exist?
- Who are the domain experts that can help collect and make sense of the relevant data?
Which algorithm type will you use (supervised, unsupervised, reinforcement learning)?
Do you have data that can be labelled? How should the data be labelled?
What data do you need to train your model? There are three types of data to consider:
- Private
- Commerical
- Open-source - You can find open source data sets at AWS and other orgs
Identify features (feature engineering) and weights.
Training data vs Validation data Don't use all the data to train your model, instead keep some of it away from the model so that you can use it to validate the performance of the model.
A general rule:
- 80% for training
- 10% for validation
- 10% for testing (what's the diff betweend validating and testing???)
Choose a machine learning algorithm (supervised, unsupervised, reinforcement)
Evaluate and tune the model (iteratively)
- Underfitting is when the model does not preform well on the training data (it cannot make the desired relationships)
- Overfitting is when the model performs well on training data, but not on the evaluation data. In other words, the model memorizes the training data as opposed to learning the relationships between features and labels.
The goal of training is a model that is balanced(?) and generalizes well
Finally, when you are happy with the model, you can deploy it in SageMaker
Module 4 - ML Tools and Services
The three layers of the ML stack:
- The data layer
- The model layer
- The deployment and monitoring layer
There are many libraries that are used in ML
AWS has instances that are optimized for ML
- C5 and P3 instances
AWS IoT Greengrass - brings intelligience to edge devices
AWS Elastic Inference instance - add GPU support to instances that helps with ML processing (and apparently save up to 75% of ML by saving on GPU over provisioning)
AWS ML Managed Services
- Computer vision
- Rekognition
- Textract
- Chat interface
- AWS Lex
- Speech
- AWS Polly
- AWS Trnascript
- Fraud detection
- Amazon Fraud Detector
- Language
- Comprehend
- Translate
- Reccomendations
- Personalize
- SageMaker
- prepare, build, train & tune, deploy and manage models
- Sage maker can help you with every step in the ML pipeline
SageMaker Tools
- Notebooks that can be shared
- Instance types
- Data Visualization
- Model selection
- Deployment
- Marketplace integration
A SageMaker notebook instance is a machine learning (ML) compute instance that is running the Jupyter Notebook application