Professional Documents
Culture Documents
2 Fabio Galasso
Fundamentals of Data Science | Winter Semester 2020
Classification
Email: Spam / Not Spam?
Online Transactions: Fraudulent (Yes / No)?
Tumor: Malignant / Benign ?
4 Fabio Galasso
Fundamentals of Data Science | Winter Semester 2020
Linear classifiers in a nutshell
5 Fabio Galasso
Fundamentals of Data Science | Winter Semester 2020
Sentiment analysis
pizza was
awful… ice
cream was 1 2 +
awesome…price
was awesome
hot dog was
awesome…martin
i was awesome… 1 2 +
price was awful
everything
was 1 0 -
awful
wine was
awful..pasta was
awful…dessert was 3 1 -
awful..view was
6 Fabio Galasso
Fundamentals of Data Science | Winter Semester 2020
(Yes) 1
Malignant ?
(No) 0
Tumor Size Tumor Size
Logistic Regression:
Outline
13 Fabio Galasso
Fundamentals of Data Science | Winter Semester 2020
Outline
14 Fabio Galasso
Fundamentals of Data Science | Winter Semester 2020
Classification with Logistic Regression
Logistic Regression Model
Want
0.5
Sigmoid function 0
Logistic function
Interpretation of Hypothesis Output
= estimated probability that y = 1 on input x
Example: If
z
Suppose predict “ “ if
predict “ “ if
Decision Boundary
x2
3
2
1 2 3 x1
Predict “ “ if
Non-‐linear decision boundaries
x2
-‐1 1 x1
-‐1
Predict “ “ if
x2
x1
Classification with Logistic Regression:
Learn 𝚯’s
Training
set:
m examples
24 Fabio Galasso
Fundamentals of Data Science | Winter Semester 2020
Logistic Regression Algorithm
25 Fabio Galasso
Fundamentals of Data Science | Winter Semester 2020
Digression:
Perceptron
Logistic Regression Algorithm
27 Fabio Galasso
Fundamentals of Data Science | Winter Semester 2020
Outline
29 Fabio Galasso
Fundamentals of Data Science | Winter Semester 2020
Newton’s Method for Optimization
Recap on logistic regression
31 Fabio Galasso
Fundamentals of Data Science | Winter Semester 2020
Optimization algorithm
Given , we have code that can compute
-‐
-‐ (for )
33 Fabio Galasso
Fundamentals of Data Science | Winter Semester 2020
Newton’s Method
• When 𝚯 is a vector
34 Fabio Galasso
Fundamentals of Data Science | Winter Semester 2020
Outline
35 Fabio Galasso
Fundamentals of Data Science | Winter Semester 2020
Exponential Family of Distributions
Recap:
Bernoulli and Gaussian distributions
37 Fabio Galasso
Fundamentals of Data Science | Winter Semester 2020
The Exponential Family of Distributions
38 Fabio Galasso
Fundamentals of Data Science | Winter Semester 2020
More on the Bernoulli Distribution
• 𝑃 𝑦, 𝜂 = 𝑏 𝑦 exp( 𝜂 𝑇 𝑇 𝑦 − 𝑎 𝜂 )
39 Fabio Galasso
Fundamentals of Data Science | Winter Semester 2020
More on the Bernoulli Distribution
𝜙
• [log 𝑦 + log 1 − 𝜙 ]
1−𝜙
40 Fabio Galasso
Fundamentals of Data Science | Winter Semester 2020
More on the Gaussian Distribution
• 𝑃 𝑦, 𝜂 = 𝑏 𝑦 exp( 𝜂 𝑇 𝑇 𝑦 − 𝑎 𝜂 )
41 Fabio Galasso
Fundamentals of Data Science | Winter Semester 2020
Outline
42 Fabio Galasso
Fundamentals of Data Science | Winter Semester 2020
Generalized Linear Models
Generalized Linear Models (GLM)
44 Fabio Galasso
Fundamentals of Data Science | Winter Semester 2020
Generalized Linear Models (GLM)
46 Fabio Galasso
Fundamentals of Data Science | Winter Semester 2020
GLM for Ordinary Least Squares
47 Fabio Galasso
Fundamentals of Data Science | Winter Semester 2020
GLM for Logistic Regression
48 Fabio Galasso
Fundamentals of Data Science | Winter Semester 2020
Generalized Linear Models:
Multi-Class Classification
Multiclass classification
Email foldering/tagging: Work, Friends, Family, Hobby
x2 x2
x1 x1
Multinomial Classification
x2
x1
53 Fabio Galasso
Fundamentals of Data Science | Winter Semester 2020
Multinomial and the Exponential Family
54 Fabio Galasso
Fundamentals of Data Science | Winter Semester 2020
Multinomial and the Exponential Family continued
55 Fabio Galasso
Fundamentals of Data Science | Winter Semester 2020
Softmax Regression
56 Fabio Galasso
Fundamentals of Data Science | Winter Semester 2020
Learn θ’s for Softmax Regression
57 Fabio Galasso
Fundamentals of Data Science | Winter Semester 2020
x2
One-‐vs-‐all (one-‐vs-‐rest):
x1
x2 x2
x1 x1
x2
Class 1:
Class 2:
Class 3:
𝑐 x1
ℎΘ (𝑥) = 𝑃 𝑦 = 𝑐 x; Θ (𝑐 = 1,2,3)
One-‐vs-‐all
60 Fabio Galasso
Fundamentals of Data Science | Winter Semester 2020
Additional References
• Chapters 2.4, 4 and 4.1 and 4.3 in [Bishop, 2006. Pattern Recognition and Machine
Learning]
• https://beginningwithml.wordpress.com/2018/06/22/3-4-softmax-regression/
61 Fabio Galasso
Fundamentals of Data Science | Winter Semester 2020
Thank you
Acknowledges: slides and material from Andrew Ng, Alessandro Panconesi, Marco Bressan