Evaluating a Hypothesis
๋ค์์ ํตํด ์์ธก ์ค๋ฅ์ ๋ํ ๋ช ๊ฐ์ง ๋ฌธ์ ํด๊ฒฐ์ ์ํํ๋ค.
- ๋ ๋ง์ training example์ ๊ฐ์ ธ์ค๊ธฐ
- ์์ feature ์ธํธ๋ฅผ ์๋
- ์ถ๊ฐ์ ์ธ feature์ ์๋
- ๋คํญ์ feature์ ์๋
- $\lambda$ ๊ฐ์ ๋๋ฆฌ๊ฑฐ๋ ์ค์ด๊ธฐ
์ด์ ์๋ก์ด hypothesis๋ฅผ ํ๊ฐํ๋ ๋ฐฉ๋ฒ์ ๋ํด ์์๋ณด์.
hypothesis๋ training example์ ๋ํด ๋ฎ์ ์ค์ฐจ๋ฅผ ๊ฐ์ง๊ณ ์์ ์ ์์ง๋ง, ์์ง ๋ถ์ ํํ๋ค $($overfitting ๋๋ฌธ$)$. ๋ฐ๋ผ์ hypothesis๋ฅผ ํ๊ฐํ๊ธฐ ์ํด์๋ ์ฃผ์ด์ง training example ๋ฐ์ดํฐ์ ์ ๋ํด ๋ ๊ฐ์ ์ธํธ๋ก ๋ถ๋ฆฌํ์ฌ์ผ ํ๋ค: training set & test set. ๋ณดํต training set๋ ๋ฐ์ดํฐ์ 70% ์ ๋์ด๊ณ , test set์ ๋ฐ์ดํฐ์ 30% ์ ๋์ด๋ค.
์ด 2๊ฐ์ ์ธํธ๋ฅผ ์ฌ์ฉํ ์๋ก์ด ํ๋ก์์ ๋ ๋ค์๊ณผ ๊ฐ๋ค.
- training set๋ฅผ ์ฌ์ฉํด์ $\theta$๋ฅผ ํ์ตํ๊ณ $J_{train}(\theta)$๋ฅผ ์ต์ํ์ํด.
- test set ์ค์ฐจ $J_{test}(\theta)$๋ฅผ ๊ณ์ฐํจ.
The test set error
- linear regression์ ๋ํด์: $J_{test}(\theta) = \frac {1}{2m_{test}} \sum_{i=1}^{m_{test}} (h_{theta}(x_{test}^{(i)}) - y_{test}^{(i)})^{2}$
- ๋ถ๋ฅ์ ๋ํด์๋ ์๋ชป ๋ถ๋ฅ๋ ์ค์ฐจ๋ฅผ ๋ค์๊ณผ ๊ฐ์ด ๊ณ์ฐํ๋ค.
์ด๊ฒ์ ์๋ชป ๋ถ๋ฅ๋ ๊ฒฐ๊ณผ์ ๊ธฐ๋ฐ์ ๋ ์ค์ฐจ ๊ฒฐ๊ณผ๋ฅผ ์ด์ง๊ฐ 0๊ณผ 1๋ก ์ค๋ค. test set์ ๋ํ ํ๊ท test error๋ ๋ค์๊ณผ ๊ฐ๋ค.
์ด๊ฒ์ test data์์ ์๋ชป ๋ถ๋ฅ๋ ๋ถ๋ถ์ ๋น์จ์ ์๋ ค์ค๋ค.
Model Selection and Train/Valid/Test Sets
ํ์ต ์๊ณ ๋ฆฌ์ฆ์ด training set์์ ์ ์๋ํ๋ค๊ณ ํด์ ์ด๊ฒ์ด ์ข์ hypothesis๋ผ๊ณ ์ต๋ถ๋ฆฌ ํ๋จํ ์๋ ์๋ค. ์ด๊ฒ์ด overfit๋ ๊ฒ์ด์ด์ test set์๋ ๋ ์ ์ข์ ๊ฒฐ๊ณผ๋ฅผ ๋ณด์ฌ์ค ์๋ ์๋ค. ํ๋ผ๋ฏธํฐ๋ฅผ ํ์ตํ ๋ฐ์ดํฐ ์ธํธ์์ ์ธก์ ํ hypothesis์ ์ค์ฐจ๋ ๋ค๋ฅธ ๋ฐ์ดํฐ ์ธํธ์ ์ค์ฐจ๋ณด๋ค ๋ฎ๋ค.
์๋ก ๋ค๋ฅธ polynomial degree๋ฅผ ์ฌ์ฉํ ๋ง์ ๋ชจ๋ธ๋ค์ด ์ฃผ์ด์ง๋ฉด, ์ฒด๊ณ์ ์ธ ๋ฐฉ๋ฒ์ผ๋ก '์ต๊ณ ์' ํจ์๋ฅผ ์ฐพ์์ผ ํ๋ค. hypothesis์ ๋ชจ๋ธ์ ์ ํํ๊ธฐ ์ํด์๋, ๊ฐ๊ฐ์ polynomial degree๋ฅผ ํ ์คํธํด์ ๋์จ error ๊ฒฐ๊ณผ๋ฅผ ์ดํด๋ด์ผ ํ๋ค.
๋ฐ์ดํฐ์ ์ 3๊ฐ์ ์ธํธ๋ก ๋ถ๋ฆฌํ๋ ๋ฐฉ๋ฒ์ ๋ค์๊ณผ ๊ฐ๋ค.
- Training set: 60%
- Cross validation set: 20%
- Test set: 20%
์ด์ 3๊ฐ์ ์๋ก ๋ค๋ฅธ ๋ฐ์ดํฐ ์ธํธ์ ๋ํด์ ๋ถ๋ฆฌ๋ error ๊ฐ์ ๊ณ์ฐํ ์ ์๋ค.
- ๊ฐ๊ฐ์ polynomial degree์ ๋ํ training set์ ์ฌ์ฉํด์ ํ๋ผ๋ฏธํฐ $\theta$๋ฅผ ์ต์ ํํ๋ค.
- cross validation set๋ฅผ ์ฌ์ฉํด์ ๊ฐ์ฅ ์ ์ error๋ฅผ ๊ฐ์ง๋ polynomial degree d๋ฅผ ์ฐพ๋๋ค.
- test set๊ณผ $J_{test}(\theta^{(d)})$๋ฅผ ์ฌ์ฉํด์ ์ผ๋ฐํ๋ error๋ฅผ ์ธก์ ํ๋ค.
์ด ๋ฐฉ์์ ์ฌ์ฉํ๋ฉด polynomial degree d๋ test set๋ฅผ ์ฌ์ฉํด์ ํ์ต๋์ง ์๋๋ค.
'Lecture ๐งโ๐ซ > Coursera' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[Machine Learning] Machine Learning Algorithm Application (0) | 2023.03.28 |
---|---|
[Machine Learning] Bias vs Variance (0) | 2023.03.27 |
[Machine Learning] Backpropagation in Practice (0) | 2023.03.27 |
[Machine Learning] Cost Function & Backpropagation (0) | 2023.03.26 |
[Machine Learning] Neural Networks (0) | 2023.03.20 |