kwan's note

overfitting- 과적합 본문

ML and AI/Machine learning - Andrew Ng

overfitting- 과적합

kwan's note 2021. 1. 26. 23:15
반응형

출처: machine learning by andrew ng, stanford cousera lecture

수강일시: 2021.01.26

 

reminder-by-kwan.tistory.com/88

 

Cost function -비용함수/ 손실함수

출처: machine learning by andrew ng, stanford cousera lecture 수강일시: 2021.01.24 www.coursera.org/learn/machine-learning/home Coursera | Online Courses & Credentials From Top Educators. Join for F..

reminder-by-kwan.tistory.com

 

데이터를 모델링함에 있어 어떠한 가설함수 h를 선택할지는 매우 중요한 요소이다. 그 가설함수의 차수 혹은 형태를 정함에 있어 다양한 문제가 있는데 underfitting과 overfitting이 대표적이다.

 

underfitting은 실제 데이터보다 차수가 낮거나 차원이 낮은 함수를 사용함으로서 제대로 적합하지 못한것이고

overfitting은 과도하게 적합함으로서 기존데이터 즉 learning 데이터 셋에서는 매우 잘 작동하나 테스트 데이터 셋이나 real world problem에서는 매우 큰 오차를 보이는 경우를 말한다.

 

 

위와 아래 그림이 underfitting, fit, overfitting의 예이다.

 

 

아래는 수업에서 언급된 underfitting, overfitting이다.

Underfitting is when the form of our hypothesis function h maps poorly to the trend of data. It's usually caused by a function that is too simple or use too few features. At the other extreme, overfitting, or high variance, is caused by a hypothesis function H that fits the available data but does not generalize well to predict new data. It is usually caused by complicated function that creates a lot of unnecessary curves and angles unrelated to the data.

 

underfitting의 문제를 해결하기 위해서는 다양한 방법이 존재하는데 가장 쉽고 직관적인 방법은 눈으로보고

어떤 함수를 파악할것인지 생각해 적용하는것이다.

 

하지만 이런 방법은 사람으로 인한 bias가 생길 수 있고 만약 feature의 차원이 1, 2가 넘어간다면 이는 실질적으로 불가능해질 것이다.

따라서 아래와 같은 방법을 시도할 수 있다.

 

1. feature의 갯수를 줄인다.

- 어떤 feature를 이용하고 어떤 feature를 버릴지 정한다.

- 또는 model selecting algorithmn을 채용해 알고리즘이 버릴 feature를 선택해 버리도록 한다.

 

2.regularization

- 모든 feature를 버리지 말고 사용하나 일부 데이터의 theta값을 매우 낮춘다.

- regularization은 필요도가 적당히 낮은 특징들이 많은경우 효과적이다.

 

이후 수업에서 이러한 underfitting을 해결하는 방법을 하나씩 배워보도록 하겠습니다.

반응형