ROKO

How many data need for ML model? 본문

Artificial Intelligence/Machine Learning

How many data need for ML model?

RO_KO 2023. 2. 28. 17:54
728x90

딥러닝은 모델의 parameter 자체가 많아 많은 데이터가 필요하다는 것을 알고 있다.

관련 생각을 하던중 궁금증이 생겼다.

  1. 어떠한 기준을 바탕으로 어느정도의 데이터가 필요할까? 
  2. 딥러닝과 머신러닝을 학습시키기 위한 양은 비슷할까?

1번 질문

일반적으로 두가지의 대답을 할 수 있는데, "어떠한 프로젝트를 진행중이냐는 의존성"과 "많으면 많을수록 좋다"라는 것이다.

 

의존성에 대해 먼저 살펴보자

모델을 학습함에 있어 고려해야할 사항은 어떤 것들이 있을까.

  • 문제의 복잡성 (정형, 비정형, 단변량, 다변량)
  • 모델의 복잡성 (머신러닝, 딥러닝)
  • 목표 성능 (허용 에러 수치)

 문제의 복잡성이란 데이터의 단순함 정도를 의미할 수 있다. 대표적인 머신러닝 데이터셋인 iris를 예를 든다면 꽃에 대한 길이정보를 가지고 분류하므로 머신러닝 알고리즘으로 충분하다. 하지만 이미지 분류같은 경우 CNN을 이용한 딥러닝 모델을 사용해야 하므로 데이터 요구량이 증가한다.

다른 관점에서는 데이터 자체의 문제가 될수도 있다. 문제를 해결하기 위한 데이터가 충분하지 않거나 노이즈가 많이 있는 데이터라면 feature engineering이나 data augmentation 기법 적용이 필요할 것이다. 데이터가 충분하지 않은 경우는 화산폭발 예측 문제가 있다. 화산폭발은 자주 일어나지 않으며 확보된 데이터의 양도 많지 않다. 노이즈가 많은 경우는 반도체 공정 데이터가 있다. 공정 중에 어떠한 기준으로 측정하는 과정에서 NaN값이 많이 포함되거나 잘못측정되는 경우가 있다. 데이터 증강(data augmentaiton)은 다음기회에 자세히 알아보자.

 

 모델의 복잡성은 말그대로 머신러닝과 딥러닝의 차이로 볼 수 있을 것이다. 물론 머신러닝을 앙상블하게 된다면 나름의 복잡성이 증가하기는 하나 딥러닝에 비해서는 높다고 볼 수 없다. 머신러닝과 딥러닝의 차이는 feature engineering의 여부라고 생각한다. 머신러닝은 잘 정제된 feature를 넣었을때 분류 혹은 회귀 하는 알고리즘을 학습하는 반면 딥러닝은 비정형 데이터로부터 feature와 그 feature를 구분하는 알고리즘 둘다 학습하기 때문이다. 그러므로 딥러닝은 머신러닝보다 많은 데이터를 요구한다.

 

 목표 성능은 학술적인 관점보다는 산업계의 관점에서 바라보면 좋을 것 같다. 제빵회사에 불량인 제품을 걸러내는 딥러닝 알고리즘을 탑재한 기기를 사용한다고 가정하자. 이 기기는 80%확률로 작동한다고 하였을때 1억을 더 투자하면 5%의 성능 향상을 이뤄낸 기기를 사용할수 있다.

"우리는 1억을 당장 갖다 바쳐야 할까?" 1억으로 5%향상을 이룬 기기로 얻는 이익과 1억의 자본이 가지는 기회비용과 금액의 가치를 저울질해야 할 것이다. 다른 예로 암세포를 판별하는 모델을 개발할 시는 데이터의 정확도 뿐만 아니라 XAI로서의 기능도 발전시켜야 할 것이다. 이런 다양한 조건들을 고려하여 가장 적절한 비용을 통해 적정의 정확도를 가지는 모델을 만들게 되는 경우가 있다. 데이터는 산업분야의 목적에 따라서도 영향을 받는다.

 

 

학술점 관점에서 데이터 요구량 

AI를 연구하면서 학술적으로 의미있는 성능을 뽑기위한 데이터는 위에서 설명한 예로 다양한 요인이 있어 task 별로 알아보는게 좋은데 가장 좋은 방법 중 하나는 관련 task의 논문의 experiment를 살펴보는것이다. 실험 조건, 가정, 데이터 종류 등등 다양한 값들이 설명되어 있다. 

 

The most common way to define whether a data set is sufficient is to apply a 10 times rule. This rule means that the amount of input data (i.e., the number of examples) should be ten times more than the number of degrees of freedom a model has. Usually, degrees of freedom mean parameters in your data set. 

많은 블로그에서 설명하길 "10배의 규칙"이라고 하는데 모델 전체 크기의 최소 10배의 데이터가 있어야 한다는 것이다. (ML기준)

 

이외에 다양한 추측법이 있다.

  • Computer vision: For image classification using deep learning, the rule of thumb is that each classification requires 1000 images. If you use a pre-trained model, you can use less data to train.
    \(\rightarrow\) 각 image label을 분류하기위해 딥러닝을 학습시키려면 최소 1000장의 이미지가 있어야한다 
  • The learning curve is a graph of the relationship between the error and the amount of training data. We can build a learning curve function, and then use nonlinear regression or weighted nonlinear regression to fit the learning curve, and then find the number of samples under the expected accuracy.
    \(\rightarrow\) error graph를 regression해서 적당한 sample data 양을 찾자
  • The VC dimension is a measure of the complexity of the model. The more complex the model, the larger the VC dimension. N is the number of samples required, d is the failure probability, and ε is the learning error.
    \(\rightarrow\) model complexity 지표인 VC차원, 10배의 규칙에 따르면 VC보다는 데이터가 많아야 한다

 

Traditional machine learning algorithm : 데이터가 많을수록 지수적으로 증가 후 일정 시간 이후 안정화, 수렴한다.

Deep learning : 데이터 양에 따라 로그비율만큼 증가한다.

 

 

 

 

[참고자료]

https://machinelearningmastery.com/much-training-data-required-machine-learning/

https://ai-forum.com/opinion/how-much-training-data-is-needed-for-machine-learning/

https://postindustria.com/how-much-data-is-required-for-machine-learning/

 

How Much Data Is Required for Machine Learning? – PostIndustria

If you ask any data scientist how much data is needed for machine learning, you’ll most probably get either “It depends” or “The more, the better.” And the thing is, both answers are correct.  It really depends on the type of project you’re wo

postindustria.com

 

https://towardsdatascience.com/how-do-you-know-you-have-enough-training-data-ad9b1fd679ee

 

How Do You Know You Have Enough Training Data?

There is some debate recently as to whether data is the new oil [1] or not [2]. Whatever the case, acquiring training data for our machine…

towardsdatascience.com

 

728x90

'Artificial Intelligence > Machine Learning' 카테고리의 다른 글

What is Neural Networks?  (0) 2023.03.06
Is validation necessary?  (0) 2023.02.28
What is SVMs?  (2) 2022.12.20
What is Linear Classification? [Ⅱ]  (0) 2022.12.19
Comments