LG Aimers 4기 그리고 Linear Regression

2024. 1. 10. 09:19컴퓨터 전공 공부/LG Aimers

반응형

LG Aimers: AI전문가과정 4차

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

 

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

 

Linear Regression

- Hypothesis set H : a set of lines
ℎ𝑤 𝑥 = 𝜃0+ 𝜃1𝑥1 + ⋯ + 𝜃𝑑𝑥𝑑 = 𝜽T𝒙
𝜽: model parameter (learnable parameter)

ℎ𝑤 𝑥 = 𝜃0+ 𝜃1𝑘1(𝑥1) + ⋯ + 𝜃𝑑𝑘𝑑(𝑥𝑑) = 𝜽T𝑘(𝒙)
e.g. 𝑘𝑛 𝑥 = 𝒙^n
Linear model with a set of arbitrary functions (more general case).
Linear in 𝜽, not necessarily in x

- Many advantages : good for a first try
• Simplicity : easy to implement and interpret
• Generalization : higher chance 𝐸𝑡𝑒𝑠𝑡 ≈ 𝐸𝑡𝑟𝑎𝑖𝑛
• Solve regression and classification problems

- Univariate problem, Multivariate problem
입력 변수 갯수에 따라서.

-Which predictor?
Hypothesis class 

Univariate linear model

-How good is a predictor?
Loss function

Minimizing MSE

-How to compute the best predictor?
Optimization algorithm

Gradient descent algorithm
Normal equation

-평균제곱오차(MSE, Mean Squared Error)
머신러닝에서는 Cost Function(손실함수 혹은 비용함수)에서 주로 쓰입니다.

1. 오차의 제곱을 평균으로 나눈 것이다.
2. MSE가 0에 가까울수록 추측한 값이 원본에 가까운 것이기 때문에 정확도가 높다고 할 수 있다.

ㄴ 이는 2학년 2학기 확률과 통계 수업에서 살짝 배웠던 거 같다.

찾아보면서 평균절대오차도 같이 공부했다.

-평균절대오차(MAE, Mean Absolute Error)
회귀평가를 위한 지표로 주로 쓰인다. 기계 학습 모델의 퀄리티를 요약하고 평가하기 위한 여러 메트릭 중 하나라고 할 수 있다.MSE와 마찬가지로 0에 가까울수록 좋은 모델이라고 할 수 있다.

-Normal equation (Least Square)
  Analytic solution of 𝜽

데이터 분석에서 회귀를 진행했을 때 오차를 줄여 줄 수 있는 방법론이다. 최소제곱법에 의하여 얻어지는, 미지수의 개수와 같은 수의 방정식이다.

• What if the dimension of the input vector hugely increases (huge computational complexity)?
• What if the matrix is not invertible (redundant features ; linearly dependent)?
-> Needs iterative algorithm (gradient descent)

-Gradient descent algorithm 경사하강법

머신러닝에서 손실함수 최소 값을 찾기 위한 다양한 방법 중 가장 일반적이며 많이 쓰이는 알고리즘. 

손실함수는 오차의 평균값을 나타내기 떄문에 손실함수가 최소값을 갖는다는 것은 실제 정답과 계산 값의 차이인 오차가 최소가 되어 미지의 데이터에 대해서 결과를 더 잘 예측 할 수 있다는 것을 의미한다. 

가중치 W에서의 직선의 기울기인 E/W로 계산되는 미분값을 이용해서 그 값이 작아지는 방향으로 진행하면서 손실 함수의 최소값을 찾는 알고리즘을 경사하강법이라고 한다.

-Gradient descent algorithm
Method to solve numerically

Outline: The function 𝐽 is the objective function that we want to optimize.
𝛼: the step size to control the rate to move down the error surface.
It is a hyper parameter, which is a positive number (c.f. 𝜃 is a learnable
parameter) 

• Start with initial parameters ɵ0, ɵ1
• Keep changing the parameters to reduce 𝐽 until achieving the minimal cost


-Quiz
What answers are correct? Select all that apply.

A. In linear regression, the solution is interpretable with input features

B. In linear regression, a hypothesis is not necessarily to be a linear form of learnable parameters

A
Correct. The score is computed as a linear combination of input features and weights; the weight explains the importance of an input feature to the final output

B
False. Linear regression model may not be a linear form of a raw data but it should be a linear
form of parameters

-Linear regression model

Linear regression model


• Can be readily solved using gradient descent
• Interpretable and lightweight; worth to try first!

반응형