1 - Machine Learning Overview
1 - Machine Learning Overview
Machine Learning
by Tran Thi Oanh
2024 VNU-IS
1
Outline
➢Machine Learning: Concepts and examples
➢Types of ML models
o Supervised
o Unsupervised
o Semi-supervised
o Reinforcement Learning
➢Steps to build a ML model
➢How to choose a good ML models
➢Q&A
2
Machine Learning: Concepts and
examples
3
4
➢What do you think is the difference between programming a machine
to follow rules and training a machine to learn from data?
5
Traditional Programming
Data
Computer Output
Program
Machine Learning
Data
Computer Program
Output
7
What is ML?
➢Machine learning (ML) is a field of study in artificial
intelligence concerned with the development and study
of statistical algorithms that can learn
from data and generalize to unseen data and thus
perform tasks without explicit instructions.
Wikipedia
8
Development of ML
9
➢Why do you think the concept of "machine learning" emerged in the
1950s, long before we had today's powerful computers?
➢How do you think the rise of big data has influenced the development
of ML?
10
Applications in Business and Economics
11
12
Types of Machine Learning
13
➢If you were training a computer to identify objects in pictures, what
information would you need to give it?
➢How do you think a robot could learn to clean a room without being
told the rules (reinforcement learning)?
14
Types of Machine Learning
➢Supervised (inductive) learning
o Training data includes desired outputs
➢Unsupervised learning
o Training data does not include desired outputs
➢Semi-supervised learning
o Training data includes a few desired outputs
➢Reinforcement learning
o Rewards from sequence of actions
15
Supervised ML
➢Q: If you were teaching someone to tell the difference between apples
and oranges, what kinds of features would you tell them to look for?
➢A: Color, shape, texture, maybe even taste.
➢Q: What do you think the machine is looking for when distinguishing
cats from dogs?
➢A: It’s looking at patterns in the image like the shape of the ears, the
length of the fur, or even colors. The machine uses these features to
make its decision.
16
Supervised ML (2)
17
Supervised ML algorithms
➢Given many labeled
examples, the machine
gets supervision through
correct labels to detect
patterns.
➢ML algorithms: ANN, DT,
Naïve Bayes, k-NN, etc.
Source: https://www.javatpoint.com/supervised-machine-learning
18
Un-supervised ML
➢Q: Have you ever been in a situation where you didn’t know
everyone’s name but still noticed groups forming? What clues did you
use to figure out who might belong together?
➢A: I might notice how they dress or what they’re talking about.
➢Q: How do you think a machine groups data without being told what
the groups are?
➢A: The machine looks for patterns, like similarities in features (just
like you might notice how people dress or what they’re talking
about), and groups similar things together.
19
20
21
Supervised vs. un-supervised
22
Un-supervised ML algorithms
➢k-means
➢HAC
➢Etc.
23
Reinforcement Learning
➢Q:Think of a video game where you earn points for doing something right
and lose points for making mistakes. How do you improve as you keep
playing?
➢A:By learning which actions get me more points and avoiding mistakes.
24
Reinforcement learning
➢Task
Learn how to behave successfully to achieve a goal while interacting with an
external environment
o Learn via experiences (trial and error) !
➢Examples
o Game playing: player knows whether it win or lose, but not know how to
move at each step
o Control: a traffic system can measure the delay of cars, but not know how to
decrease it.
25
RL is learning from interaction
26
Steps to build a ML model
27
Define the Problem
➢What is the task you want to solve?
o Is it a classification task (e.g., spam detection), a regression task (e.g.,
predicting house prices), or another type (e.g., clustering)?
➢What is the expected outcome?
o Decide if you want the model to make predictions (supervised learning),
discover patterns (unsupervised learning), or make decisions based on
rewards (reinforcement learning).
28
Collect and Understand the Data
➢Gather relevant data:
o Collect data from sources like databases, surveys, or APIs. The data should
relate to the problem you're solving.
➢Understand the data:
o Explore the data’s structure (rows and columns) and types of variables
(numerical, categorical, text, etc.).
➢Formulate features and labels:
o In supervised learning, decide which column will be the label (what you want
to predict) and which will be features (what helps make the prediction).
29
Clean and Prepare the Data
➢Handle missing data:
o Remove or fill in missing data (e.g., using mean, median, or more advanced
techniques).
➢Remove outliers:
o Outliers can skew results, so you may want to remove or handle them.
➢Normalize/Scale the data:
o Features like age or income may have very different ranges. Normalize them so that
all features are on a similar scale, especially for algorithms sensitive to scale (e.g.,
neural networks).
➢Encode categorical data:
o Convert categorical features (e.g., "Yes/No", "Red/Blue") into numerical format,
using techniques like one-hot encoding or label encoding.
30
Split the Data (Train/Test Split)
31
Choosing the right models
32
Train models
➢Fit the model to the training
data:
o During this phase, the model
learns patterns from the training
data to make predictions. The
model adjusts its internal
parameters based on the
features and labels in the
training set.
➢Monitor training performance:
o Keep an eye on loss metrics to
ensure the model is learning well
and not overfitting.
33
Train Models - Loss functions
34
Evaluate models
35
Tuning models
➢Principle about iterative improvement:
o Machine learning is an iterative process involving continuous refinement.
➢Principle about training and optimization:
o Learning process involves optimizing a loss function to minimize prediction
errors.
36
Source: https://www.linkedin.com/pulse/guide-hyperparameter-tuning-tushar-aggarwal
37
Key issues in choosing right ML
models
38
Model
39
Choosing the right models
➢Define the task and goal: What type of prediction or pattern
recognition is required?
o Is the problem a prediction (supervised) or pattern-finding (unsupervised)
task?
o Are the labels in the dataset available for supervised learning?
➢Analyze the data: Check for data size, features, and quality.
o How much data do you have? Is it enough to support complex models?
o What is the nature of the data—numerical, categorical, text, or image?
40
Choosing the right models
➢Choose models based on performance, complexity and scalability.
o Is the problem simple or complex? Do you need a simple model (logistic
regression, decision tree) or a more complex one (SVM, neural network)?
o How much computational power and time are available for training the
model?
o Will the model need to handle a large dataset or be deployed in real-time
systems?
➢Model interpretation
o Does the application require transparency? For example, do you need to
explain predictions to stakeholders?
o Are there regulatory requirements for model interpretability?
41
Choosing the right models
➢Optimize the model:
o Fine-tune hyperparameters and check for overfitting or underfitting.
42
Overfitting and underfitting
44
Strategies for reduce overfitting
Strategies normally involves adding some kind of regularisation either to the
network or the dataset.
➢Reducing batch size - adds more noise every step.
➢Reducing model size - so that model can't just 'remember' the dataset.
➢Adding regularisation to the network e.g.:
o L2 and L1 regularisation
o Dropout
o Batch normalisation
➢Early stopping
➢Collect more data or Data augmentation
45
Model Evaluation
46
Interpretation
➢Many modern ML models, especially deep learning models,
function as "black boxes," meaning they produce predictions
without providing clear explanations for how the results are
derived. This is particularly problematic in areas like
healthcare or law, where decisions can have significant
impacts on individuals.
48
Q&A
49
1. In your own words, how would you explain what a machine learning
model is to someone who has never heard of it before? Can you give a
real-world example of how it might be used?
2. When training a machine learning model, what do you think happens if
the training data contains errors or mislabeled examples? How do you
think this would affect the model's ability to make good predictions?
3. Think of an everyday activity (e.g., recommending movies, filtering spam
emails, or detecting fake news). How do you think a machine learning
model could be used in that situation? What kind of data would the
model need to learn from, and what predictions would it make?
50
4. Imagine you trained a machine learning model to recognize dogs, but it
only ever saw pictures of one type of dog (e.g., golden retrievers). What
might happen if you asked the model to recognize a different breed, like a
poodle? Why is it important for a model to generalize rather than memorize
specific examples?
5. Given a task like recognizing handwritten numbers, what factors would
you consider when choosing the right machine learning model to use? How
might different types of models (e.g., decision trees, neural networks, etc.)
approach the task differently?
6. What are some ethical considerations we should think about when
building machine learning models? How could a model that makes
predictions affect people in ways we may not expect?
51
52
53
Questions
4
54
55
56