ML Midterm Cheatsheet

Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

1.

ML Basics Types of learning:


Supervised (inductive) learning: Given
Machine Learning is an approach to learn complex training data + desired outputs (labels)
patterns from existing data and use these patterns to Unsupervised learning: Given training
make predictions on unseen data. data (without desired outputs)
Semi-supervised learning: Given
o ML is used when:
training data + a few desired outputs
Human expertise does not exist
Reinforcement learning: Rewards from
Humans can’t explain their expertise
sequence of actions
Models must be customized
Models are based on huge amounts of data
Recognizing patterns (facial identities)
Generating patterns (images)
Recognizing anomalies (fraud)
Prediction (stock price)

2. Data
preparation
Key steps in the process: • Data labeling • EDA • Preprocessing
& Feature Engineering • Splitting • Augmentation
EDA is the cyclical process that can be done at any steps of the ML project’s life
cycle, which answer important questions and make it easier to extract insights

o Data preprocessing has 2 kinds of processes:


Prepration: data cleaning, missing values,
outlier removing, feature engineering
Transformation: scaling, encoding
o Data cleaning: Image - crop, resize, clip; Text -
lower, stem, lemmatize, regex, remove stopwords +Training set: used by the model to
o Data missing: MAR (related to another variable), optimize internal weights, +Validation
MNAR (related to the value itself), MCAR (no pattern) set’s performance: is checked to tune
o Handling missing values: deletion, imputation model hyperparameters, +Test set’s
Data leakage happens when your training data contains information o Feature engineering: often require subject final measure is how model performs
about the target, but similar data will not be available when the model is expertise, data knowledge, and fast generation on unseen data
used for prediction (solution: target values after prediction aren’t usable) o Removing outliers:

3. Modelling & Deep learning o The perceptron: Forward propagation

AI is any technique that enables computers to mimic human behaviour, including:(ML is


ability to learn without explicitly being programme, including:(DL is how neural networks
extract patterns from data))
o Why ML now? (ML was since 1952)

o Activation function is purposed to introduce non-linearities


into the neural network.
4. ML
Evaluation

Multiple-layer neural network has one or more hidden layers between input and output
layers, including:(Single-layer neural network has only 1 hidden layer between input
and output layers, including:(Perceptron is the simplest form of neural networks, a linear
algorithm in ML usually used for supervised learning of binary classification).

o If the test-set labels influence the learned


model, accuracy estimates will be biased.
o Limitations of using only 1 train/test
partition: maybe not enough data to make
sufficiently large train and test sets; 1 train
set doesn’t tell us how senstive accuracy is to a particular train sample
Low/ High bias: fewer/more
assumptions are taken to
build the target function, so
model will/ will not closely
Mean squared error measures the average match the training data.
squared difference between the predicted Low/ High variance:
and the actual target values within a dataset model is less/ very sensitive
Bias is the difference between the model’s to changes in the training data
predicted value and the actual value. and produce a consistent/
Variance is the amount by which the variable estimate of the target
performance of a predictive model changes function when trained on
when it is trained on different subsets of the different subsets of data from
How to evaluate a machine learning model? training data. the same distribution.
MSE for regression; Precision, Recall for
Classification; Bias and Variance for parameter tuning.
Reduce bias: Use more complex model; Increase number
of features; Reduce regularization of model; Increase size
of training data.
Reduce variance: Simplify model; Cross-validation;
Feature selection; Regularization of model; Early stopping
Ideal scenario for a machine learning model: the
model is able to capture the underlying patterns in the data
(low bias) and is not too sensitive to changes in the
training data (low variance).

5. ML Deployment How to deploy ML models (Frequency, Reason,


Example):
It is integrating a ML model into an existing Batch (Periodical, not need immediate results,
production environment where it can take in TripAdvisor hotel rank)
an input and return an output Real-time (Upon request, multiple users with parallel
requests and need immediate results, Google translation)
Purpose: make the predictions from a trained
Hybrid (Real-time by default but common queries are
machine learning model available to others, whether
precomputed and stored, GrabFood with batch
that be users, management or other systems
predictions for restaurant recommendations and real-time
Pros and cons of Notebooks: Pros suitable for PIC, predictions for items in each restaurant
interactive environment, can see output fast; Cons: not Streaming (Event-based, more synchronous process
suitable for production, not memory-efficient than real-time, Facebook ads or TikTok recommendation
Edge (Direct on client side and can be edge or cloud
Build a spam detection computing, fast and offline but limited because of smaller
web app, project workflow: hardware, Web browser or car or IoT hardwares)

MLOPs = ML = DevOps
A sequence of steps implemented to deploy an ML model to the production environment; It is easy to
create ML models that can predict on the data we feed but challenging to create such models that
are reliable, fast, accurate, and can be used by a large number of users.
Tools used for ML pipeline:
(1) Flask: create API as interfaces of models, (2) MLFlow: for model registry, (3)
Github: for code version control, (4) Data version control (DVC): version control
6. Explainable AI of the datasets and to make pipeline, (5) Cookiecutter: project templates

XAI allows human users to comprehend and trust Attribution problem: Attribute a model’s prediction on an input to features
the results and output created by ML algorithms. of the input, but Attributions do not explain: ● Feature interactions ● What
training examples influenced the prediction ● Global properties of the model

Why use Explainable AI? KEY CONCEPTS:


Need for Transparency and Feature Importance: how much each feature (input variable) contributes to the output of a model => how decisions are
Explainability in AI => Safety made
Model Validation => Learning Model Internals: a deep dive into the structure/ operations within the model, i.e. weights, biases, and the architecture of
Scientific Consistency => Trust neural networks => how information is processed
Why NOT use Explainable AI? Explaining by Examples: using specific data points to show how the model behaves under certain conditions or why it
Data privacy & security makes certain decisions => boost understanding in practical scenarios
Complexity of AI models as they Intrinsic Interpretable Models: are models designed to be naturally interpretable, such as decision trees or linear
evolve over time models, where the decision-making process is transparent and easy to follow
Human bias (parameters set by humans) (Cheat sheet by Hoang for BANA4020 class, please distribute freely to our classmates)

You might also like