Decision Tree
Decision Tree
๋ฐ์ดํฐ๋ฅผ ๋ถ์ํ์ฌ ์ด๋ค ์ฌ์ด์ ์กด์ฌํ๋ ํจํด์ ์์ธก ๊ฐ๋ฅํ ๊ท์น๋ค์ ์กฐํฉ์ผ๋ก ๋ํ๋.
๋ถ๋ฅ(Classification)์ ํ๊ท(Regression) ๋ฌธ์ ์ ์ ์ฉ ๊ฐ๋ฅ.
๊ณ์ฐ๋ณต์ก์ฑ ๋๋น ๋์ ์์ธก ์ฑ๋ฅ์ ์ง๋.

Example (Process of Decsion Tree)
Find the feature and criteria that best differentiate the data.
Q) How to findd the criteria that best differentiate the data?
-> Maximize the information gain. (Minimize the Impurity (Entropy))

Entropy, Impurity
๋ถ์๋ (Impruty)
ํด๋น ๋ฒ์ฃผ ์์ ์๋ก ๋ค๋ฅธ ๋ฐ์ดํฐ๊ฐ ์ผ๋ง๋ ์์ฌ ์๋๊ฐ?
Entropy
๋ถ์๋๋ฅผ ์์น์ ์ผ๋ก ๋ํ๋ธ ์ฒ๋

Entropy Example

Impurity Indicator
Entropy
Gini-Index

Rish of Overfitting
Decision trees tend to overfit on data with a large number of features. Getting the right ratio of samples to number of features is important, since a tree with few samples in high dimensional space is very likely to overfit.
We have to limit the maximum depth, the maximum number of nodes, minimum number of data for one node to split.

Pruning
Prevent overfitting using pruning.

Cost Function of Pruning
๐ถ๐ถ(๐)=๐ธ๐๐(๐)+๐ผร๐ฟ(๐)
๐ถ๐ถ(๐): ์์ฌ๊ฒฐ์ ๋๋ฌด์ ๋น์ฉ ๋ณต์ก๋ (=์ค๋ฅ๊ฐ ์ ์ผ๋ฉด์ terminal node ์๊ฐ ์ ์ ๋จ์ํ ๋ชจ๋ธ์ผ์๋ก ์์ ๊ฐ)
๐ธ๐ ๐ (๐): ๊ฒ์ฆ ๋ฐ์ดํฐ์ ๋ํ ์ค๋ถ๋ฅ์จ
๐ฟ(๐): terminal node์ ์ (๊ตฌ์กฐ ๋ณต์ก๋)
๐ด๐๐โ๐: ๐ธ๐ ๐ (๐)์ ๐ฟ(๐)๋ฅผ ๊ฒฐํฉํ๋ ๊ฐ์ค์น (์ฌ์ฉ์์ ์ํด ๋ถ์ฌ, ๋ณดํต 0.01~0.1์ ๊ฐ์ ์ฌ์ฉ)
Summary
์์ฌ๊ฒฐ์ ๋๋ฌด๋ ํ๋ฒ์ ํ๋์ฉ์ ์ค๋ช ๋ณ์๋ฅผ ์ฌ์ฉํ์ฌ ์์ธก ๊ฐ๋ฅํ ๊ท์น๋ค์ ์งํฉ์ ์์ฑํ๋ ์๊ณ ๋ฆฌ์ฆ.
ํ๋ฒ ๋ถ๊ธฐ ๋๋ง๋ค ๋ณ์ ์์ญ์ ๋๊ฐ๋ก ๊ตฌ๋ถํ ๋ค ๊ฐ ์์ญ์ ์๋๊ฐ ์ฆ๊ฐ(์ํธ๋กํผ๊ฐ ๊ฐ์)ํ๋ ๋ฐฉํฅ์ผ๋ก ํ์ต์ ์งํํจ.
์ ๋ ฅ ๋ณ์ ์์ญ์ ๋ ๊ฐ๋ก ๊ตฌ๋ถํ๋ **์ฌ๊ท์ ๋ถ๊ธฐ(recursive partioning)**์ ๊ตฌ๋ถ๋ ์์ญ์ ํตํฉํ๋ **๊ฐ์ง์น๊ธฐ(pruning)**์ ๋๊ฐ์ง ๊ณผ์ ์ผ๋ก ๋๋จ.
์์ฌ๊ฒฐ์ ๋๋ฌด๋ ๊ณ์ฐ๋ณต์ก์ฑ ๋๋น ๋์ ์์ธก ์ฑ๋ฅ์ ๋ด๋ ์ฅ์ ์ ์ง๋.
ํ์ง๋ง, ๊ฒฐ์ ๊ฒฝ๊ณ(decision boundary)๊ฐ ๋ฐ์ดํฐ ์ถ์ ์์ง์ด์ด์ ํน์ ๋ฐ์ดํฐ์๋ง ์ ์๋ํ๋ ํ๊ณ๊ฐ ์์.
์ด๋ฌํ ๋ฌธ์ ๋ฅผ ๊ทน๋ณตํ๊ธฐ ์ํด ๋๋คํฌ๋ ์คํธ์ ๊ฐ์ ๊ธฐ๋ฒ์ ์ฌ์ฉ.
๋๋คํฌ๋ ์คํธ๋?
๊ฐ์ ๋ฐ์ดํฐ์ ๋ํด ์์ฌ๊ฒฐ์ ๋๋ฌด๋ฅผ ์ฌ๋ฌ ๊ฐ ๋ง๋ค์ด์ ๊ทธ ๊ฒฐ๊ณผ๋ฅผ ์กฐํฉํด์ ์์ธก ์ฑ๋ฅ์ ๋์ด๋ ๊ธฐ๋ฒ
๋์ผํ ๋ฐ์ดํฐ๋ก๋ถํฐ ๋ณต์์ถ์ถ์ ํตํด 30๊ฐ ์ด์์ ๋ฐ์ดํฐ์ ์ ๋ง๋ค์ด์ ๊ฐ๊ฐ์ ์์ฌ๊ฒฐ์ ๋๋ฌด๋ฅผ ์ ์ฏ์ ๋ค ํ์ต ๊ฒฐ๊ณผ๋ฅผ ์ทจํฉํ๋ ๋ฐฉ์์ผ๋ก ๋์
References
Theoretical Explanation
https://bkshin.tistory.com/entry/%EB%A8%B8%EC%8B%A0%EB%9F%AC%EB%8B%9D-4-%EA%B2%B0%EC%A0%95-%ED%8A%B8%EB%A6%ACDecision-Tree
https://ratsgo.github.io/machine%20learning/2017/03/26/tree/
Python Implementation of Decision Tree
https://towardsdatascience.com/construct-a-decision-tree-and-how-to-deal-with-overfitting-f907efc1492d
Scikit-learn documentation
https://scikit-learn.org/stable/modules/tree.html
MATHLAB Example
fitctree & fitrtree (instruction & algorithm)
https://kr.mathworks.com/help/stats/fitctree.html
https://kr.mathworks.com/help/stats/fitrtree.html
View Decision Tree
https://kr.mathworks.com/help/stats/view-decision-tree.html
Prediction Using Classification and Regression Trees
https://kr.mathworks.com/help/stats/prediction-using-classification-and-regression-trees.html
Last updated
Was this helpful?