Lecture 02 (3hrs) Linear Regression and Logistic Regression
Lecture 02 (3hrs) Linear Regression and Logistic Regression
March 2022
Introduction to linear regression
Mathematical model
Pseudo-inverse of matrix Introduction to linear regression
Logistic regression
Summary
Outline
1. Linear regression
2. Logistic regression
3. Summary
• Vector format
3
Linear regression
with one variable y
• Training dataset
x
4
Linear regression
with one variable y
• Optimization :
Minimum mean-square error x
• Loss function
5
Linear regression
with one variable
• Least square method : Find a best fit
line , minimize the sum of Euclidean distance from
the samples to the line 。
• Partial derivative
6
Linear regression
with one variable
• Two equations with two unknowns
7
Linear regression
with one variable
• Two equations with two unknowns
8
Multivariate
linear regression
• Training set Color root shape sound good/bad
9
Multivariate
linear regression
• Vector Color root shape sound good/bad
• Parameter
• Optimization
10
Multivariate
linear regression
• Loss function Color root shape sound good/bad
• Prediction
12
•log-linear regression
• log-linear regression
• unit-step function
• non-differentiable
• Not continuous
• Sigmoid function
14
Logistic Regression
• logistic function
• GLM
15
Logistic Regression
• 几率( odds) : positive probability/ negative
probability
16
Logistic Regression
• Logistic regression : utilize linear regression to fit log probability.
(Decision through probability, interpretable )
17
Logistic Regression
• Formula
18
Maximum likelihood method
• Given dataset :
• log-likelihood
• 似然项展开:
19
Maximum likelihood method
• log-likelihood
20
maximum likelihood method
• Log-likelihood
• Maximum likelihood
21
Gradient descent
22
Newton’s Method
• Start with an initial guess, then to approximate the function by
its tangent line, and finally to compute the x-intercept of this
tangent line. This x-intercept will typically be a better
approximation to the original function's root than the first guess,
and the method can interative
23
Multi-class Learning
• Idea : divide into some Binary classification
problem
• Approach :
• One v.s. One x2
24
Multi-class Learning
• One v.s. One
x2
• Combination: N(N-1)/2
• Vote x1
25
Multi-class Learning x2
• 结果可通过投票
• 训练 N 个分类器,选择置信度最高
26
Multi-class Learning x 2
x1
• Many v.s. Many : Error Correcting Output Code ( ECOC )
• Coding : divide M times , M classifiers
• Decoding : Compare
27
Class-imbalance x2
• Approach :
• 欠采样 (under-sampling)
• 过采样 (over-sampling)
• 阈值移动 (threshold-moving): rescaling 再缩放
28
Introduction
Weight
Height
Linear Regression
From Linear Regression to Logistic Regression
Obese Obese
Prob. of Obesity
Prob. of Obesity
Threshold
Weight Weight
Linear Regression Logistic Regression