yuns
Linear Regression 본문
반응형
Linear Regression
- 한 개 이상의 입력 변수와 결과값 사이의 선형 관계(1차로 이루어진 직선)를 모델링하는 방법론
- Classification - Discrete-valued output
- 주는 입력변수(키, 몸무게, 등) 을 선형으로 조합하여 모델링
- target value는 무조건 하나임
- $(x, y)$: one training example
- $(x^{(i)}, y^{(i)})$: i$^{th}$ training example
- Hypothesis: $h_{\theta}(x) + \theta_0 + \theta_1 x$
- 값들을 대입해서 나온 값(예측값)과 실제값 차이의 제곱의 합이 최소화되도록
- $min_{\theta_0 \theta_1} = \frac{1}{2m}\sum(h_{\theta}(x^{i}) - y^i)^2 $(m: training개수)
- 최소화해야할 함수를 cost function = objective function이라 함(squared error function)
Coss Function
- cost function을 $J(\theta)$라 할때, $\theta$는 학습하는 값들
Gradient Descent
- loss function이 낮아지도록 찾아가는 방법(최적화 알고리즘)
- local minima를 찾아가는..
- $\theta_0 = \theta_0 - \alpha \frac{d}{d\theta_0}J(\theta_0, \theta_1)$가 수렴할때까지 반복
- $y=2x^2-4x+5$
- $J(\theta _1) = 2\theta _1 ^2 - 4 \theta _1 + 5) = 2(\theta _1 -1)^2 + 3$
- $\frac{d}{d\theta _1} = 4theta _1 - 4$
- $\theta _1 = 4$ -> 12 --> 4 - 0.1 *(12)
- $\theta _1 = 0 $ -> -4 --> 0 - 0.1 * (-4)
- 두 개의 변수가 있을 경우,
- $J(a, b) = \frac{1}{2 * 2} (a^2 + 3b^2 - 2ab + 4a - 5b + 3) (a=-1, b=2, \alpha=0.1)$
- $\frac{J}{a} = 2a - 2b + 4$ -->$a = -1 - 0.1*(2 * -1 - 2 * 2 + 4) = -1 - 0.1* (-2)$
- $\frac{J}{b} = 6b - 2a - 5$ --> $b = 2 - 0.1 * (6 * 2 - 2 * (-1) - 5) = 2 - 0.1 * 9$
- $J(a, b) = \frac{1}{2 * 2} (a^2 + 3b^2 - 2ab + 4a - 5b + 3) (a=-1, b=2, \alpha=0.1)$
실습 자료
반응형
'goorm 수업 정리 > Machine Learning' 카테고리의 다른 글
Dimensionality Reduction (0) | 2021.09.01 |
---|---|
Cross Validation and Dimensionality Reduction (0) | 2021.08.30 |
Regularization (0) | 2021.08.27 |
Logistic Regression (0) | 2021.08.26 |
Multiple Variable Linear Regression (0) | 2021.08.25 |
Comments