-
Pstage - Image ClassificationAI/5주차 2021. 9. 3. 10:28
현재 문제점
- class imbalance가 심하다
- validation accuracy와 제출 시 accuracy가 차이가 많이 난다
- 모델이 잘 예측하지 못하는 구간이 존재한다 (나이의 경계값)
- 데이터셋을 분석한 결과 비슷한 class에 배경이 비슷한 경우가 있다
- class들이 상호 배타적이지 않다.
문제 원인 분석
- class imbalance의 경우 기본적으로 주어지는 dataset이 원인
- data leakage 발생: 학습할 때 사용되는 인물이 validation에 존재하여 validation이 제 역할을 수행하지 못한다 / overfitting
- 데이터가 부족 / 사람이 하기도 어려운 task
- 모델에게 원치 않는 feature를 학습 시킬 수 있다.
- class간 연관성이 있다.
해결 방안
1. class imbalance의 경우 다음과 같은 시도를 해볼 수 있다
샘플링
- oversampling minority classes - 일반적으로 oversampling의 효과가 더 좋다
- undersample majority classes
- generate synthetic samples (SMOTE) - 이미지에 잘 이용되는거 같지는 않다
- pseudo labeling - unlabel data를 이용해서 모델에 데이터를 추가로 준다
https://www.stand-firm-peter.me/2018/08/22/pseudo-label/
Stand firm Peter
Peter's playground.
www.stand-firm-peter.me
Loss Function
- Weighted Cross Entropy: 부족한 클래스의 loss에 가중치를 곱해준다.
- Focal Loss: Focal loss는 분류 에러에 근거한 loss에 가중치를 부여하는데, 샘플이 이미 올바르게 분류되면 그에 대한 가중치는 감소한다. 즉, 문제가 있는 loss에 더 집중하는 방식으로 불균형한 클래스 문제를 해결.
- F1 Loss: F1-Score를 기준으로 한 loss이다. https://gist.github.com/SuperShinyEyes/dcc68a08ff8b615442e3bc6a9b55a354
F1 score in PyTorch
F1 score in PyTorch. GitHub Gist: instantly share code, notes, and snippets.
gist.github.com
2. validation과 test score의 차이는 data leakage와 overfitting을 막는 방법들을 이용해 볼 수 있다.
data leakage의 경우 한 사람의 데이터는 train / val 하나의 세트에만 존재하도록 하였다. 이를 통해서 validation - 리더보드간 f1 score의 차이를 확연하게 줄일 수 있었다.
overfitting을 막는 방법으로는 데이터를 augmentation을 통해 늘리는 방법, 모델에 drop out을 추가하거나 model complexity를 낮추는 방법 등이 있다.
참고
- Imbalance 해결방법
https://journalofbigdata.springeropen.com/articles/10.1186/s40537-019-0192-5
Survey on deep learning with class imbalance - Journal of Big Data
The purpose of this study is to examine existing deep learning techniques for addressing class imbalanced data. Effective classification with imbalanced data is an important area of research, as high class imbalance is naturally inherent in many real-world
journalofbigdata.springeropen.com