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?