Regression Loss Function Remind
Regression Loss Function은 Error의 크기를 측정할 수 있었음
하지만 Classification Loss Function은 옳고 그름 2가지 밖에 없음 (단, Class가 2개 이상일 수 있음)
Decision Tree
가장 기본적인 Classification Model
Decision Tree는 Regression Problem도 함께 적용 가능
Classification Measuring Impurity for Split
순도 (Homogeneity)를 최대로 증가시키는 방향
불순도 (Impurity) 혹은 불확실성 (Uncertaionty)을 최소로 감소시키는 방향
- Measuring Impurity 1: Gini Index (Max 0.5, 0일 때 가장 잘 나누어진 것)
- Measuing Impurity 2: Entropy (0일 때 가장 잘 나누어진 것)
- Measuring Impurity 3: Misclassification Error (잘 사용하지 않음)
기본적으로 Classification Model을 학습할 때 사용하는 Binary Cross Entropy
Decision Tree의 기본적인 원리
데이터를 분석하여 이들 사이에 존재하는 패턴을 예측 가능한 규칙 (Rules) 들의 조합으로 나타냄
Linear Regression과 다르게 Model의 Complexity를 극한으로 높일 수 있음 (Overfitting 가능성 존재)
만약 Teriminal node수가 3개 뿐이라면 새로운 데이터가 100개, 1000개가 주어진다고 해도 의사결정나무는 정확히 3종류의 답(Rule)만 출력하게 됨
Decision Tree Split 하는 원리
First Step은 불순도가 가장 낮은 Feature와 포인트를 찾음
→ 이 포인트가 Root Node
그 후 Information gain이 가장 큰 포인트를 찾아서 Split을 진행함
무한히 Partitioning (Split)을 하게 되면 100% Purity, 0% Purity가 됨 → Overfitting
Full tree를 생성한 뒤 적절한 수준에서 Teriminal node를 잘라줘야 함
Rule Extraction: 가장 중요하고 강력한 해석력을 가짐
Simple 하지만 직관력이 있음 (Simple is the Best)
Model이 복잡해 질수록 해석력은 현저히 떨어지게 됨
Model 평가 및 지표 해석
Class의 Balance가 맞는가? → 평가 지표가 달라지게 됨
TP (True Positive) 예측한 값이 Positive 실제 값도 Positive
FN (False Negative) 예측한 값이 Negative 실제 값은 Positive
FP (False Positive) 예측한 값이 Positive 실제 값은 Negative
TN (True Negative) 예측한 값이 Negative 실제 값도 Negative
정분류율 Accuracy: 정확도는 직관적으로 모델 예측 성능을 나타내는 지표
정밀도 Precision: 예측 Positive 중 실제도 Positive를 찾아낸 비율 (미처 잡아내지 못한 개수가 많더라도 더 정확한 예측이 필요한 경우)
재현율 Recall: 실제 Positive 중 올바르게 Positive를 예측해 낸 비율 (잘못 걸러내는 비율이 높더라도 참 값을 놓치는 ㅣㄹ이 없도록 eg 의학, 불량)
특이도 Specificity: 실제 Negative 중 올바르게 Negative를 찾아낸 비율
Ensemble
조화 또는 통일
어떤 데이터를 학습할 때, 여러 개의 모델을 조화롭게 학습시켜 그 모델들의 예측 결과들을 이용하여 더 정확한 예측 값을 구할 수 있음
Ensemble TOp 10 main takeaways
1. Its not all about Deep Learning
2. Choose the right problem to solve, with the right metric
3. Fine tuning your models in 5% of a project (Spend much time on Model tuning)
4. Ensembles almost always work better
5. The trend towards personalization
6. Manual curation of content is still used in practice
7. Avoid the curse of complexity
8. Learn the best practices from established players
9. Everybody is using open source
10. Make sure you have support from the executives
Ensemble의 종류
Bagging : Reduce the Variance
Stacking : Use another prediction model
Boosting : Reduce the Bias
Bagging
Reduce the Variance
Bootstrap Aggregating
Bootstrap: 표본에서 추가적으로 표본을 복원 추출하고 각 표본에 대한 통계량을 다시 계산하는 것
N개의 Data가 있으면 N개를 Randomly하게 뽑아내서 새로운 Data Set을 구성함
Bootstrap을 진행하면 확률 상 뽑히지 못한 데이터는 36.8%가 됨
- Model Result Aggregating Method 1: Majority voting
- Model Result Aggregating Method 2: Weighted voting 1
- Model Result Aggregating Method 3: Weighted voting 2
그 뒤의 내용들은 정리하다가 날라감
추후 시간이 되면 다시 정리하도록 하겠음
'[데이터분석] > Python | AI | 머신러닝' 카테고리의 다른 글
Clustering (2) | 2024.09.16 |
---|---|
eXplainableMethod (1) | 2024.09.16 |
Regression Problem (0) | 2024.09.09 |
Python을 활용한 프로그래밍 확률통계_Part 4 (0) | 2024.08.01 |
Python을 활용한 프로그래밍 확률통계_Part 3 (0) | 2024.07.30 |