Lecture 1and2-Revision Part1
Lecture 1and2-Revision Part1
Input Image
INFERENCE USING ML
Output MALE/FEMALE
Output
• Spam detection prediction
• Input: email ; Output = Spam or not
• ML
Score prediction (out of 100) in ML Course
Algo
• Input: 10,12 math marks; Output = Predicted Score
Input
TASK, DATASET, FEATURES
An
st ure
fe
sw
Algorithm
Em s
er
Model
s:
ai
S
l
PA
New Email Inference Question: SPAM/HAM
M
features
/H
Algorithm
AM
TASK, DATASET, FEATURES
Output = Output =
continuous discrete Solutions
Hierarchical, Deep NN
Non-linear Model
Supervise Classificat SVR/SVM,
Regression Non-linear Model
d ion NN
Linear Model
Dimensiona
Unsupervi
lity Clustering
sed
reduction
•
HOW DO BUILD A ML ALGORITHM
The previous viewpoint was a requirement viewpoint
• Let us take an engineering viewpoint of Machine
Learning
• Machine learning consists of “tasks, models, features,
and datasets”
• To start: Pose a suitable task, Collect a good dataset,
Extract relevant features
• To solve: Choose a model to implement, Learn a model
using the dataset (learning algorithm), use the model to
…Let’s solve
MODEL, LEARNING, INFERENCE ALGORITH
SOLUTION 1: CLASSIFICATION
PROBLEM
• e.g. Spam detection problem
An
Learning
Pa
s sw
Algorithm er
t
Em
s:
Sp
ai
am
ls
• Models: straight line to divide (a linear model)
or
no
x2 x2 t
x1 x1
MODEL, LEARNING, INFERENCE ALGORITH
SOLUTION 2: REGRESSION
PROBLEM
• e.g ML1 Score prediction problem
Learning
Pa t ks
An
st h M
10 ar
Algorithm
sw
m
st a
u d th
er
s:
en s
M
ts
y y
L1
sc
o
re
?
x1 x1
MODEL, LEARNING, INFERENCE ALGORITH
SOLUTION 3: CLUSTERING
PROBLEM
• e.g. News grouping problem
Learning
Co w
Cl er
Algorithm
ne
l le i t
us y
ev
ct em
te ne
s
io s
r w
n
ID s
of
s it e
fo m
r
• Model: distance based
x2 x2
x1 x1
EVALUATION METRIC: CLASSIFICATION
PROBLEM
• How do we know the solution on the right is better than the left?
x2 x2
x1 x1
EVALUATION METRIC: REGRESSION PROBLEM
y p r e d i =m x i+ b
∑¿
y y
ypre
di
ypredi
yi yi
x x
xi xi
ML EXPERIMENTS
Training Learning Training
Features Algorithm Labels
Model
Test Inference
Features Predicted
Algorithm
Labels
Evaluation Predicted
e.g. Accuracy Labels
Algorithm Test
Labels
REVISIT: SOLVING THE PREDICTIVE ANALYTICS
•
PROBLEM
Machine learning consists of “tasks, models, features,
and datasets”
Support Vector
Bayes Classifer Logistic regression
Machine
REVISIT: SOLVING THE PREDICTIVE ANALYTICS
•
PROBLEM
Machine learning consists of “tasks, models, features,
and datasets”
Constrained
Minimisation
OPTIMIZATION METHODS
Global vs local
optimum
- Neural networks
Single optimum
- SVM
MODEL DATA
SPACE SPACE
y p r e d i =m x i+ b
L ( m , b )=∑ ¿
MODEL DATA
SPACE SPACE
FITTING A STRAIGHT LINE
Score
In ML D a t a : { x i , y i }i=1 : N
course
M o d e l : y p r e d=a+ b∗ x
L o s s : J ( a , b)=∑ ¿
10th
math
FITTING A STRAIGHT LINE – COST FUNCTION
CLOSED FORM – MINIMIZE SUM OF SQUARE ERROR
GRADIENT DESCENT – MINIMIZE SUM OF SQUARE
ERROR
FN MINIMIZATION
Exercise
CLOSED FORM
ITERATIVE METHOD
′
❑
θ (n e w)=θ( o l d)−μ J (θ)
GRADIENT DESCENT
Cost function Gradient of the cost function
′
J ( θ )=1.2 ¿ J ❑
(θ)=2.4∗(θ−2)
at
′
❑
θ (n e w)=θ( o l d)−μ J (θ) θ=θ (o l d ) Gradient
Descent
θ (n e w )= θ( o l d)− μ∗2.4 (θ−2) at θ=θ (o l d )
θ (o l d )=1
C a s e 1 : μ=0.1
θ (n e w )=1−0.1∗2.4 (1− 2)=1.24
C a s e 2 : μ=0.5
θ (n e w )=1−0.5∗2.4 (1−2)=2.2
FITTING A GAUSSIAN
PROBABILISTIC CLASSIFIERS
ML ML
Algo Algo
random
Input Hair length, x Input X variable
BAYES CLASSIFIER
• Probabilistic classifiers estimate
• Question: How to
estimate mu and
sigma?
FITTING A GAUSSIAN
DENSITY ESTIMATION TASK:
WHICH GAUSSIAN IS THE BEST?
Data
{ x i }i=1 : N
Model
1 −¿ ¿¿
p(x i ∨μ , σ )= e
σ √2 π
Hair length
of women
MAXIMUM LIKELIHOOD FUNCTION
p( X∨θ)= p( x 1 x 2 .. x N ∨θ)
0.25 25%
BAYES CLASSIFIER
NAÏVE BAYES CLASSIFIER
• Probabilistic classifiers estimate
P(C =C ∨x ) k