yuns
Multiple Variable Linear Regression 본문
반응형
하나의 입력 변수가 아닌 여러 개의 입력 변수를 다루는 경우
Multiple Linear Regression
- feature = dimension = attribute
- n: feature의 개수
- $h_\theta (x) = \theta _0 x_0+ \theta _ 1 x_1 + \theta _2 x_2+ \cdots + \theta _n x_n (x_0=1)$
- 차원은 $n+1$
Feature Scaling
- feature들이 같은 구간에 분포하도록 scaling 해야 함
- 기울기가 급격히 떨어지는 구간이 있고 기울기가 너무 완만하게 떨어지는 구간이 생성되기 때문에 feature를 scaling해주는 것이 좋음
- normalize, standarization
- 방법
- 최소값과 최대값을 이용하여 scaling / [-1, 1]로 scaling
- outlier에 취약할 수가 있음
- mean normalization
- 평균과 분산을 이용하여 0이 평균이 되도록 scaling
- $\frac{x-m}{\sigma}$
- 최소값과 최대값을 이용하여 scaling / [-1, 1]로 scaling
Gradient Descent
- hypothesis: $h_\theta (x) = \theta _0 x_0+ \theta _ 1 x_1 + \theta _2 x_2+ \cdots + \theta _n x_n (x_0=1)$
- $h_\theta (x) = \theta_0 + \theta_1 x_1 + \theta_2 x_2 = \theta_0^Tx$
- $J(\theta_0, \theta_1, \theta_2) = \frac{1}{2 * 3}((\theta_0 +\theta_1 + \theta_2 * 2 - 5)^2 + (\theta_0 +\theta_1 * 3 + \theta_2 * (-1)- 3)^2 + (\theta_0 +\theta_1 * 2+ \theta_2 * 3- 4)^2)$
- 편미분
- $a = (\theta_0 +\theta_1 + \theta_2 * 2 - 5)$
- $b = (\theta_0 +\theta_1 * 3 + \theta_2 * (-1)- 3)$
- $c = (\theta_0 +\theta_1 * 2+ \theta_2 * 3- 4)$
- $\frac{J}{d\theta_0} = \frac{1}{3}(a + b + c)$ ($x_0$가 곱해짐)
- $\frac{J}{d\theta_1} = \frac{1}{3}(a + 3b + 2c)$ ($x_1$가 곱해짐)
- $\frac{J}{d\theta_2} = \frac{1}{3}(a - b + 3c)$ ($x_2$가 곱해짐)
$x_1$ | $x_2$ | y |
1 | 2 | 5 |
3 | -1 | 7 |
2 | 3 | 4 |
Polynomial Regression
- $\theta_0 + \theta_1 x + \theta_2 x^2 + \theta_3 x^3$꼴로 나타내고 싶을 경우
- --> 표에 $x^2, x^3$의 컬럼을 추가하면 됨
반응형
'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 |
Linear Regression (0) | 2021.08.24 |
Comments