LG Aimers 4기 그리고 Linear Classification

2024. 1. 12. 09:01컴퓨터 전공 공부/LG Aimers

반응형

LG Aimers: AI전문가과정 4차

Module 4. 『지도학습(분류/회귀)』 

 

ㅇ 교수 : 이화여자대학교 강제원 교수 
ㅇ 학습목표 
Machine Learning의 한 부류인 지도학습(Supervised Learning)에 대한 기본 개념과 regression/classification의 목적 및 차이점에 대해 이해하고,  다양한 모델 및 방법 (linear and nonlinear regression, classification, ensemble methods, kernel methods 등)을 통해 언제 어떤 모델을 사용해야 하는지, 왜 사용하는지, 모델 성능을 향상시키는 방법을 학습하게 됩니다.

 

- Linear Classification
Hypothesis set H : a set of lines

ℎ𝑤 (𝑥) = 𝑤0+ 𝑤1𝑥1 + ⋯ + 𝑤𝑑𝑥𝑑 = 𝒘T𝒙
𝒘: model parameter (learnable parameter)
ℎ𝑤 𝑥 = 𝑤0+ 𝑤1𝜙(𝑥1) + ⋯ + 𝑤𝑑𝜙(𝑥𝑑) = 𝒘T𝜙(𝒙)
Linear model with a set of features


Linear classification framework
-Which predictor?  Hypothesis class 
ℎ(𝑥) = sign( 𝒘T𝒙)
-How good is a predictor?  Loss function
Zero-one loss
Hinge loss
Cross-entropy loss
-How to compute the best predictor?   Optimization algorithm
Gradient descent algorithm

-Linear classification model

Linear classification model

 

-Score and margin
• Input data : 𝑥
• Predicted label : ℎ 𝒙 = sign (𝑤𝑇𝜙(𝒙))
• Target label: y

 Score : the score on an example (𝑥, 𝑦) is 𝑤 · 𝜙(𝑥), how confident we are in predicting +1.
 Margin : the margin on an example (𝑥, 𝑦) is (𝑤 · 𝜙(𝑥))𝑦, how correct we are.

-Zero-one loss
The goal is to minimize the loss
To run gradient descent, compute the gradient: 
*Gradient is zero almost everywhere!

-Hinge loss
• Zero loss if it is classified confidently and correctly
• Misclassification incurs a linear penalty w.r.t. confidence

 

 

-Cross-entropy loss
• Considers two probability mass functions (pmf) {𝑝, 1 − 𝑝} and
{𝑞, 1 − 𝑞} with a binary outcomes
• Cross entropy measures the error when approximating an
observed pmf {𝑝, 1 − 𝑝} between a fitted pmf {𝑞, 1 − 𝑞}

 

Cross-entropy loss

 

Sigmoid function
• Squash the output of the linear function
• A better approach : interpret as a probability

-Training a linear classifier
• Iterative optimization using gradient descent

1. Initialize weights at time step 𝒕 = 0
2. Compute the gradients
3. Set the direction to move :
4. Update weights
5. Iterate to next step until converging

-Multiclass classification
• Not all classification predictive models support multi -class classification.
• split the multi-class classification dataset into multiple binary classification datasets and fit a binary classification model on each.


-Advantage of linear classification
• Simple!
처음 시도하기 가장 적합한 형태이다.

• Interpretability (example in Murphy 2012)
𝑥1: the number of cigarettes per day , 𝑥2: minutes of exercise per day
The goal is to predict 𝑃(𝑌 = lung cancer)
Assume we have estimated the best parameter 𝑤 = (1.3, -1.1) to have ℎ(𝑥) = 1.3𝑥1 – 1.1𝑥2

Quiz

A. 
In a linear classification model, a hyperplane is used for a decision boundary to classify training samples, assuming samples are linearly separable. 

Correct.

B. 
Cross-entropy loss represents an error or a dissimilarity between two real values, and therefore it can be directly used to compute an error of a score value

False.
 Cross-entropy loss measures a dissimilarity of two pmfs. A sigmoid function is first applied to convert a real value into a probability between 0 and 1, and then the loss is used to compute the error value. 

C. 
A binary linear classifier can be extended to a multiclass linear classifier

Correct.
 A binary linear classifier can be extended to a multiclass classifier by applying an oneVS-all classification per class, although a binary linear classifier inherently estimates only true/false. 

Summary
• Linear classification model

• Uses a hyperplane as a decision boundary to classify samples based on a linear combination of its explanatory variables
• It has several advantages ; simplicity and interpretability
• Cross-entropy loss measures the performance of a classification model whose output is a probability value between 0 and 1. A sigmoid function is used to map a score value into a probability value.
• Multi-classification problem can be solved through one-vs-all. 

반응형