Regression problem에서는 일반적으로 loss function을 MSE로 잡는다.
하지만 test error는 위 방식과는 다름
where a test sample (x,y) is sampled from the so called test distribution D.
Overfitting and Underfitting
Training error와 test error와의 차이를 Generalization gap 라고 부른다.
Overfitting
Training example을 잘 예측하지만, test example을 잘 예측하지 못하는 것
→ 즉, Generalization이 잘 안된 것
Underfitting
Training error가 상대적으로 크기 때문에 test error도 큰 상황
→ 즉, 학습이 제대로 진행되지 않은 것으로 이해할 수 있다.
Bias and Variance
일반적으로 training example은 ground truth으로부터 noise를 살짝 가지고 있다고 가정한다.
궁극적인 목표는 h∗를 예측하는 것인데, 문제가 되는 지점은 test example의 경우에는 noise가 얼마나 되는지에 대해서 예측하기가 힘들다는 것이다.
Bias is the error that occurs due to the model not being able to capture the underlying relationship between the features and the target variable. Variance is the error that occurs due to the model being too sensitive to small changes in the training data.
Bias: A model that predicts the same value for all data points is said to have high bias. This can happen if the model is too simple and cannot capture the underlying relationship between the features and the target variable.
Variance: A model that performs well on the training data but poorly on new data is said to have high variance. This can happen if the model is too complex and is overfitting the training data.
What is “Bias”?
오른쪽에서 볼 수 있는 것처럼 데이터의 크기가 늘어나도 잘 학습되지 않는다.
→ linear model임을 가정함으로써 발생하는 문제이다.
즉 underfitting 문제는 데이터의 크기를 늘리거나 noise를 줄이는 것으로 해결할 수 없다.
What is “Variance”?
이 경우에는 데이터의 크기가 클수록 해결됨
만약 데이터의 양이 적은 경우 overfitting될 가능성이 높음
앞서 언급한 것처럼 높은 variance 문제는 많은 양의 data를 주게 되면 거의 해결할 수 있게 된다.
Bias-Variance Trade off
만약 모델이 너무 simple하고 너무 적은 parameter를 가진다면, large bias 를 가지고 small variance 를 가질 가능성이 높다. 즉 underfitting 문제를 겪게 될 가능성이 있다.
반대로 모델이 너무 복잡하고 너무 많은 parameter를 가진다면, large variance 를 가지고 small bias 를 가질 가능성이 높다. 즉 overfitting 문제를 겪게될 가능성이 높다.
만약 모델이 너무 simple하다면 large bias (but small variance)
→ 이 경우에는 일반적으로 underfitting 문제를 겪음
만약 모델이 너무 복잡하다면 large variance (but small bias)
Parametric density estimation perspective
θ^ : estimator of θ
이때 (E[θ^]−θ)2 는 bias2이고, E[θ^2]−E2[θ^] 는 variance이다.
Regression perspective
The MSE of the model hS which is trained on D={(x(i),y(i))} is defined by
이때 (h∗(x)−E[hS(x)])2는 bias2이고, E[(hS(x)−E[hS(x)])2]는 variance이다.
이때 bias는 data의 부족 때문이 아니라, family of model이 적절하게 h∗를 근사하지 못했기 떄문이다. 마찬가지로 variance는 해당 함수들의 분포가 얼마나 h∗로부터 멀어져있는지를 보는 것이다.
Generalization
Definition
Generalization refers to model’s capability to adapt properly to new/unseen data
Evaluation of Generalization power
Hold-out method
전제 : 주어진 데이터가 2개의 독립적인 set으로 partition된다.
Training set
Test set
만약 Test set이 편향되어있는 경우, 문제가 발생할 수 있다.
→ 그래서 Random sample strategy를 사용
→ 위와 같은 작업을 k번 수행하고, 평균을 처리해서 위 문제를 alleviate시킴.
K-fold cross validation
전체 데이터를 k개의 크기가 거의 유사한 mutually-exclusive subset으로 나눈다.
각각 한번씩 해당 subset을 testset으로 사용해서 test error를 확인한다.
1~2 과정을 총 k번 반복한다.
Nested cross validation
Hyper-parameter를 조정해야할 경우에 사용하는 방법
→ 어떤 hyper-parameter를 설정할 것인지에 대한 기준을 제공하는 역할을 수행
→ 그래서 등장한 set이 validation
총 Dataset을 k개의 subset으로 나눈다.
각 subset을 한번 씩 test set으로 설정한다.
나머지 k - 1개를 번갈아가면서 validation set으로 취급한다.
총 k번 1~3과정을 반복한다.
Train/Validation/Test Splitting
만약 데이터가 큰 경우에는 Nested cross validation이 너무 많은 시간이 걸린다는 단점이 존재하는데, 이 때문에 그냥 단순하게 하자는 것.
Regularization
앞서 살펴본 것처럼 bias-variance trade off가 존재하기에 model complexity를 적절하게 설정하는 것이 중요하다.
즉 parameter가 너무 커지게 되면 overfitting문제가 발생하기 때문에 이에 대한 penalty를 regularization 으로 주겠다는 것
lo,l1,l2 Regularization
l2 regularization이 대표적으로 사용되는 것이다.
Regularized loss에 대해서 Gradient descent를 하는 것은 standard gradient descent에 weight decay 과정을 하는 것으로 이해할 수 있다. ((1−ηλ)θ로 작아지게 된다.)
l0는 미분이 불가능하다는 측면때문에 gradient descent를 할 때는 잘 사용하지 않는다.