Introduccion A ML
Introduccion A ML
aprendizaje automático
TC3002B
Basic Concepts
Introduction
2023FJ - [email protected] 2
Ability to
use percepts from the outside world
not only for reacting,
What is but for improving actions in future events.
learning?
Implies that we know when and how to use this new knowledge.
When: pattern detected
How: algorithm created.
2023FJ - [email protected] 3
Example:
Imagine a supermarket chain with a hundred of stores selling
groceries to millions of customers.
Each sale has a lot of data that can be analised and converted
into information.
What is These information can be used to give people suggestions
when buying.
machine
learning? If we knew who would buy an item, we would just write
code for the computer to remind them.
2023FJ - [email protected] 4
Example:
In RoboCup agents play soccer.
There are 11 players against 11 players.
Each team has its own strategy for playing soccer.
2023FJ - [email protected] 5
The computer algorithm should be able to:
Identify patterns in the data (When)
2023FJ - [email protected] 6
“Machine learning uses data and answers to discover rules behind
a problem” Chollet (2017)
2023FJ - [email protected] 7
“A computer program is said to learn from experience E with
respect to some class of tasks T and performance measure P, if its
performance at tasks in T, as measured by P, improves with
experience E.” Mitchell, T. (1997)
2023FJ - [email protected] 8
Learning Agent
2023FJ - [email protected] 9
1. Which components of the performance element should be
learned?
Design of a
learning 2. What feedback is available to learn these components?
element
3. What representation is used for the components?
2023FJ - [email protected] 10
What can be learned?
Direct mapping from conditions on the current state to actions.
2023FJ - [email protected] 11
Components can be learned from appropriate feedback.
Example: training Tae Kwon Do, Driving a Taxi.
Type of feedback:
The most important factor in determining the nature of the learning
Feedback problem.
Three cases:
1. Supervised learning
2. Unsupervised learning
3. Reinforcement learning
2023FJ - [email protected] 12
Learning a function from examples of its inputs and outputs.
There is an input X, an output Y, and the task is to learn mapping
from input to output.
Learning
Examples:
Learn a condition-action rule for punching.
Learn to differentiate between a dog and a cat.
Regression
Classification.
2023FJ - [email protected] 13
Learning patterns in the input when no specific output values are
supplied.
2023FJ - [email protected] 14
Mix between supervised and unsupervised learning
2023FJ - [email protected] 15
The output of the system is a sequence of actions.
learning Agent must learn from reinforcement which actions are best, i.e. the
policy.
Examples:
Playing chess.
Driving politely.
Robot navigation.
2023FJ - [email protected] 16
Polynomials
Propositional logic
Neural networks
Etc.
2023FJ - [email protected] 17
Learning associations
Learn how people associate
elements (ex. buying Knowledge extraction
groceries) Learning a rule from data – it
explains the data
Rules are a form of data
Classification compression
Learn to classify elements in
Applications of different categories
Outlier detection
machine Prediction
Data that does not belong to
a class
learning Learn to predict if some
action will happen
Regression problems
Learn the curve that best fits
Pattern recognition a function to a set of points
Learn to find familiar
patterns (characters, faces,
objects, etc.)
2023FJ - [email protected] 18
Artificial Intelligence
Bayesian methods
Control theory
ML is
multidisciplinary Information theory
Philosophy
Statistics
2023FJ - [email protected] 19
Designing a learning
system
Introduction
2023FJ - [email protected] 20
Hyper-
Data Model parameter
Collection Fitting tuning
ML Process
Data Model
Preparation Evaluation
2023FJ - [email protected] 21
1. Choosing the training experience
1. Feedback
2. Control of sequence of examples
3. Distribution of examples
Designing a 2.
1.
Choosing the target function
Function that is operational
learning
system 3. Choosing a representation for the target function
1. Expressive representation
2023FJ - [email protected] 22
How to build a
dataset
2023FJ - [email protected] 23
Structured Data
ML models learn from examples
Each example is called an instance or
pattern
Dataset is formed with multiple
examples
Structured Data is organized in rows
and columns
A column is called a feature
2023FJ - [email protected] 24
Dataset
organization
and division
Training set is usually 80% of
original set
https://miro.medium.com/max/585/0*lbveKaL-MGRgppD8.png
2023FJ - [email protected] 25
When data is too big and we
can’t pass all data to computer
at once.
https://towardsdatascience.com/epoch-vs-iterations-vs-batch-size-
4dfb9c7ce9c9
2023FJ - [email protected] 26
Data Wrangling
Data might be in different
files
Cleaning, structuring,
enriching raw data Data Preparation
Assure quality and useful Analysis and optimization of
data features
Select/remove features
Consider prediction needs
Data Cleansing and computation time
Data Missing values (delete?)
Unwanted characters
Preprocessing Unwanted elements
https://miro.medium.com/max/666/0*ScsuON73dMJDC9XO.png
2023FJ - [email protected] 27
Complete data
science
pipeline
https://developer.ibm.com/articles/ba-intro-data-science-1/
2023FJ - [email protected] 28
Model
Evaluation
2023FJ - [email protected] 29
N x N matrix Actual values
N = number of classes
Predicted values
Confusion Evaluates performance of a
Matrix classification model
2023FJ - [email protected] 30
True Positive (TP)
Predicted value matches
actual
Both were positive
True Negative (TN)
Predicted value matches
actual
Both are negative
Binary
confusion False Positive (FP)
Type I error
matrix Predicted value falsely
predicted
Actual value Negative
False Negative (FN)
Type II error
https://cdn.analyticsvidhya.com/wp-content/uploads/2020/04/Basic-Confusion-matrix.png Predicted value falsely
predicted
Actual value Positive
2023FJ - [email protected] 31
Accuracy
Fraction of predictions model correctly classified
!"##$%& '#$()%&)"*+
𝐴𝑐𝑐𝑢𝑟𝑎𝑐𝑦 = ,"&-. */01$# '#$()%&)"*+
Confusion
matrix metrics For binary classification
!"#!$
𝐴𝑐𝑐𝑢𝑟𝑎𝑐𝑦 = !"#!$#%"#%$
Very simple, but does not take into consideration class imbalances
and data unevenly distributed
2023FJ - [email protected] 32
Precision
Proportion predicted positives identified correctly
!"
𝑃𝑟𝑒𝑐𝑖𝑠𝑖𝑜𝑛 =
!"#$"
Recall (Sensitivity)
Proportion actual positives identified correctly
!"
𝑅𝑒𝑐𝑎𝑙𝑙 = !"#$%
Confusion Specificity
Proportion actual negatives identified correctly
matrix 𝑆𝑝𝑒𝑐𝑖𝑓𝑖𝑐𝑖𝑡𝑦 = !%#$"
!%
metrics…
Precision used when FP is a higher concern than FN
From the predicted positives, how many are really positive?
2023FJ - [email protected] 33
F1 Score
Helps understand balance between Precision and Recall
2 '#$%)+)"* × #$%-.. ,6
𝐹1 = =2𝑥 =
Confusion !
3
!
"#$%&& '"#$()(*+
'#$%)+)"*5#$%-.. !
,6 5 ,(86589)
Used when
there is a need to balance this two metrics
Not easy to decide if Type I or Type II errors is preferred
2023FJ - [email protected] 34
When a classifier is not reporting the values we desire, we can
move the threshold for classification
2023FJ - [email protected] 35
ROC
Summarizes all confusion matrices produced with
different thresholds
2023FJ - [email protected] 36
AUC
2023FJ - [email protected] 37
Issues in
machine
learning
2023FJ - [email protected] 38
What algorithms exist for learning general target functions from
specific training examples?
Issues in When and how can prior knowledge guide the process of generalizing
from examples?
machine
learning What is the best strategy for choosing a useful training experience?
What is the best way to reduce the learning task to one or more
function approximation problems?
2023FJ - [email protected] 39
Alpaydin, Ethem (2004). Introduction to Machine Learning. The MIT Press.
Josh Starmer (2019). ROC and AUC clearly explained! StatQuest with Josh
Starmer, YouTube Channel
2023FJ - [email protected] 40