๊ด€๋ฆฌ ๋ฉ”๋‰ด

Doby's Lab

Entropy์™€ Gini Impurity์— ๋Œ€ํ•˜์—ฌ: Decision Tree๋Š” ์–ด๋–ป๊ฒŒ ๋งŒ๋“ค์–ด์งˆ๊นŒ, Classification ๋ณธ๋ฌธ

AI/Concepts

Entropy์™€ Gini Impurity์— ๋Œ€ํ•˜์—ฌ: Decision Tree๋Š” ์–ด๋–ป๊ฒŒ ๋งŒ๋“ค์–ด์งˆ๊นŒ, Classification

๋„๋น„(Doby) 2023. 7. 27. 23:13

๐Ÿ“„ Intro

Decision Tree (CART)๋ผ๋Š” ๋จธ์‹ ๋Ÿฌ๋‹ ๋ชจ๋ธ์€ ๋ฐ์ดํ„ฐ๋ฅผ Root Node์— ์ „๋‹ฌํ•˜๋ฉด์„œ ์ˆ˜๋งŽ์€ Node๋ฅผ ๊ฑฐ์น˜๋ฉฐ ์—ฌ๋Ÿฌ ์กฐ๊ฑด๋“ค๋กœ ํ•„ํ„ฐ๋งํ•˜์—ฌ Terminal Node(Leaf Node)์— ๋„์ฐฉํ•˜๊ณ , '์–ด๋–ค Class์ธ์ง€ (Classification)', '์–ด๋–ค ๊ฐ’์ธ์ง€ (Regression)'์„ ํŒ๋ณ„ํ•ฉ๋‹ˆ๋‹ค. ์ •ํ™•๋„๋ฅผ ๋†’์ด๊ธฐ ์œ„ํ•ด์„œ๋Š” ์กฐ๊ฑด๋“ค์ด ๋งŽ๊ธฐ๋„ ํ•ด์•ผ๊ฒ ์ง€๋งŒ ํŒ๋ณ„ํ•˜๋Š” ๊ธฐ์ค€(Criterion)์ด ๋ช…ํ™•ํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.

 

์•„๋ž˜ Decision Tree Visualization์—์„œ ๊ทธ ๊ธฐ์ค€์€ Root Node์— ์žˆ๋Š” petal width <= 0.75๋‚˜ Right-Child Node์— ์žˆ๋Š” petal length <= 4.75์™€ ๊ฐ™์€ ํ…์ŠคํŠธ๋“ค์„ ๋งํ•ฉ๋‹ˆ๋‹ค.

์ถœ์ฒ˜: Data Analytics (https://vitalflux.com/visualize-decision-tree-python-sklearn-library/)

๊ทธ๋ž˜์„œ ์ด๋ฒˆ ํฌ์ŠคํŠธ์—์„œ ์•Œ์•„๋ณผ ๊ฒƒ์€ 'Decision Tree Node์— ์žˆ๋Š” ์กฐ๊ฑด๋“ค์€ ๋ฌด์Šจ ๊ธฐ์ค€์œผ๋กœ ๋งŒ๋“ค์–ด์ง€๋Š”๊ฐ€?'์— ๋Œ€ํ•ด ์•Œ์•„๋ด…๋‹ˆ๋‹ค.


๐Ÿ“„ ๋ถˆ์ˆœ๋„, ๋ถˆํ™•์‹ค์„ฑ

์ข‹์€ ๊ธฐ์ค€์œผ๋กœ ํŒ๋ณ„๋˜๊ธฐ ์œ„ํ•ด์„œ๋Š” ๊ทธ ๊ธฐ์ค€์ด '๋ฐ์ดํ„ฐ๋ฅผ ์–ด๋–ป๊ฒŒ ๋‚˜๋ˆ„์—ˆ๋Š”๊ฐ€'์— ๋Œ€ํ•ด ์ง‘์ค‘ํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. ํŠธ๋ฆฌ์˜ ๊ด€์ ์—์„œ ๋งํ•˜์ž๋ฉด, Parent Node๋กœ๋ถ€ํ„ฐ ๋ถ„ํ• ๋œ Child Node์—์„œ ๋ฐ์ดํ„ฐ๋Š” ๋” ๋ช…ํ™•ํ•ด์กŒ๋Š”๊ฐ€?๋ฅผ ์•Œ์•„๋ณด๋ฉด ๋ฉ๋‹ˆ๋‹ค.

 

'๋” ๋ช…ํ™•ํ•ด์กŒ๋Š”๊ฐ€'์— ๋Œ€ํ•œ ์˜๋ฏธ๋Š” ์˜ˆ๋ฅผ ๋“ค์–ด ์„ค๋ช…ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค.

Class๊ฐ€ A, B๊ฐ€ ์žˆ๊ณ , ๊ทธ์— ๋Œ€ํ•œ ๊ฐ ๋ฐ์ดํ„ฐ๊ฐ€ 10๊ฐœ์”ฉ ์กด์žฌํ•˜๊ณ , Decision Tree๋ฅผ ํ†ตํ•ด ํ•™์Šต์„ ํ•œ๋‹ค๊ณ  ๊ฐ€์ •ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค.

Parent Node: {A = 10, B = 10}

๊ทธ๋ฆฌ๊ณ , ํŠน์ •ํ•œ Criterion์— ์˜ํ•ด ์•„๋ž˜์™€ ๊ฐ™์ด Split ๋˜์—ˆ๋‹ค๊ณ  ํ•ฉ์‹œ๋‹ค.

Left Child Node: {A = 5, B = 5}, Right Child Node: {A = 5, B = 5}

์ž˜ ๋‚˜๋ˆ„์–ด์ง„ ๊ฒŒ ๋งž๋‚˜์š”? ์•„๋‹™๋‹ˆ๋‹ค. ์ž˜ ๋‚˜๋ˆ„์–ด์กŒ๋‹ค๋ฉด Child Node์—์„œ ์ด Node๋Š” ์–ด๋– ํ•œ ์ •๋ณด๋ฅผ ๋‹ด๊ณ  ์žˆ๋Š”์ง€์— ๋Œ€ํ•œ ์„ ๋ช…๋„๊ฐ€ ๋šœ๋ ทํ–ˆ์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. ์•„๋ž˜์™€ ๊ฐ™์€ ๊ฒฝ์šฐ์˜ Node๊ฐ€ ์–ด๋–ค ์ •๋ณด์„ฑ์„ ๊ฐ€์ง€๊ณ  ์žˆ๋Š”์ง€ ๋ช…ํ™•ํ•ด ๋ณด์ด์ฃ .

Left Child Node: {A = 8, B = 2}, Right Child Node: {A = 2, B = 8}

 

  • ์ด์ฒ˜๋Ÿผ Node๊ฐ€ ์–ด๋–ค ์ •๋ณด์„ฑ์„ ๊ฐ€์กŒ๋Š”์ง€ ๋ชจ๋ฅด๊ฒ ๊ฑฐ๋‚˜, Node๊ฐ€ ๊ฐ€์ง„ Class ๋น„์œจ์ด ๊ท ๋“ฑํ•ด ๋ณด์ผ ๋•Œ ํ•ด๋‹น Node์˜ ๋ถˆ์ˆœ๋„๊ฐ€ ๋†’๋‹ค๊ณ  ํ•˜๊ณ ,
  • ํŠน์ •ํ•˜๊ฒŒ ์–ด๋–ค Class์˜ ๋น„์œจ์ด ๋†’์•„ ๋ณด์ธ๋‹ค, ์ด Node๋Š” ์ด ์ •๋ณด๋ฅผ ๊ฐ€์ง€๊ณ  ์žˆ๋‹ค๊ณ  ํ•  ์ˆ˜ ์žˆ์„ ๋•Œ ํ•ด๋‹น Node์˜ ๋ถˆ์ˆœ๋„๊ฐ€ ๋‚ฎ๋‹ค๊ณ  ํ•ฉ๋‹ˆ๋‹ค.

๊ทธ๋ž˜์„œ, Decision Tree๋Š” Node๋ฅผ Split ํ•˜์—ฌ ํ•˜์œ„ Node๋“ค์— ๋Œ€ํ•œ ๋ถˆ์ˆœ๋„๋ฅผ ์ค„์—ฌ๊ฐ€๋ฉด์„œ ํ•˜์œ„ Node๋“ค์˜ ์ •๋ณด์˜ ๋ถˆํ™•์‹ค์„ฑ์„ ์ค„์ด๋Š” ๊ฒƒ์ด ๋ชฉํ‘œ์ž…๋‹ˆ๋‹ค. ์•„๋ž˜์—์„œ๋Š” ์ •๋ณด์˜ ๋ถˆํ™•์‹ค์„ฑ์„ ๋‚˜ํƒ€๋‚ผ ์ˆ˜ ์žˆ๋Š” 2๊ฐ€์ง€ ์ฒ™๋„ Entropy์™€ Gini Impurity์— ๋Œ€ํ•ด ์•Œ์•„๋ด…์‹œ๋‹ค.


๐Ÿ“„ Entropy

์œ„์—์„œ ๋งํ–ˆ๋“ฏ์ด ์ •๋ณด์˜ ๋ถˆํ™•์‹ค์„ฑ์ด ๋†’์€ ๊ฒฝ์šฐ๋Š” ๋…ธ๋“œ๊ฐ€ ๊ฐ€์ง€๊ณ  ์žˆ๋Š” ๋ฐ์ดํ„ฐ๊ฐ€ ๊ฑฐ์˜ ๊ท ๋“ฑํ•œ ๊ฒฝ์šฐ์ž…๋‹ˆ๋‹ค. ์ฆ‰, ๋ฐ˜๋Œ€๋กœ ๋‚ฎ์€ ๊ฒฝ์šฐ๋ฅผ ์ƒ๊ฐํ•˜๋ฉด ๊ทน๊ณผ ๊ทน์œผ๋กœ ๊ฑฐ์˜ Proportion์„ ์ฐจ์ง€ํ•˜์ง€ ์•Š๊ฑฐ๋‚˜, ๋Œ€๋ถ€๋ถ„์˜ Proportion์„ ์ฐจ์ง€ํ•˜๋Š” Distribution์ด ๋ถˆํ™•์‹ค์„ฑ(= ๋ถˆ์ˆœ๋„)์ด ๋‚ฎ์€ ๊ฒฝ์šฐ๋ผ๊ณ  ๋ณผ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

๊ทธ๋Ÿฌํ•œ ๋ถˆํ™•์‹ค์„ฑ์„ ์ž˜ ๋‚˜ํƒ€๋‚ผ ์ˆ˜ ์žˆ๋Š” Criterion ์ค‘ ํ•˜๋‚˜๋Š” Entropy์ž…๋‹ˆ๋‹ค. ํ•จ์ˆ˜์— ๋Œ€ํ•ด์„œ ๋ฐ”๋กœ ์•Œ์•„๋ณด๋ฉด ์•„๋ž˜์™€ ๊ฐ™์ด ์ƒ๊ฒผ์Šต๋‹ˆ๋‹ค.

$$ Entropy = -\sum_{i=1}^{n}p_{i}\log_{2}p_{i} $$

  • \(p_{i}\) = ํ˜„์žฌ Node์—์„œ ๊ฐ€์ง€๊ณ  ์žˆ๋Š” ๋ฐ์ดํ„ฐ ์ง‘ํ•ฉ์— ๋Œ€ํ•ด i-th class์˜ ๋น„์œจ์„ ๋‚˜ํƒ€๋ƒ…๋‹ˆ๋‹ค.
  • \(n\) = class์˜ ๊ฐœ์ˆ˜

 

์œ„ 2๊ฐ€์ง€ ์ผ€์ด์Šค๋ฅผ ๊ทธ๋Œ€๋กœ ์‚ฌ์šฉํ•ด ๋ด…์‹œ๋‹ค.

  • {A = 5, B = 5}

$$ -(\frac{5}{10}\log_{2}(\frac{5}{10}) + \frac{5}{10}\log_{2}(\frac{5}{10})) = -(-0.5 -0.5) = 1 $$

  • {A = 8, B = 2}

$$ -(\frac{8}{10}\log_{2}(\frac{8}{10}) + \frac{2}{10}\log_{2}(\frac{2}{10})) = -(-0.2568 - 0.4642) = 0.721 $$

 

ํด๋ž˜์Šค์˜ ๋น„์œจ์ด ๊ทน์ ์ผ์ˆ˜๋ก ์—”ํŠธ๋กœํ”ผ๊ฐ€ ๋‚ฎ๊ฒŒ ๋‚˜์˜ต๋‹ˆ๋‹ค. ์ด๊ฒŒ ๊ฐ€๋Šฅํ•œ ์ด์œ ๋Š” Geogebra๋ฅผ ํ†ตํ•ด \(-x\log_{2}{x} (0 \leq x \leq 1)\)์„ ๊ตฌํ˜„ํ•ด ๋ดค์Šต๋‹ˆ๋‹ค.

0๊ณผ 1์— ๊ทผ์ ‘ํ• ์ˆ˜๋ก 0์— ๊ฐ€๊นŒ์›Œ์ง€๋Š” ๊ฒƒ์„ ๋ณด์•„ ๋ฐ์ดํ„ฐ์—์„œ ํด๋ž˜์Šค์˜ ๋น„์œจ์ด ๊ทน๋ช…ํ• ์ˆ˜๋ก ๋ถˆํ™•์‹ค์„ฑ์ด ์ค„์–ด๋“ ๋‹ค๋Š” ๊ฒƒ์„ ์•Œ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.


๐Ÿ“„ Gini Impurity

๊ทธ๋‹ค์Œ์€ Gini Impurity๋ผ๋Š” Criterion์ž…๋‹ˆ๋‹ค. Entropy์™€ ๋งˆ์ฐฌ๊ฐ€์ง€๋กœ ๋‚ฎ์„์ˆ˜๋ก ์ •๋ณด์˜ ๋ถˆ์ˆœ๋„๊ฐ€ ๋‚ฎ๊ณ , Node์˜ ์ˆœ์ˆ˜์„ฑ์ด ๋†’์€ ๋œป์„ ๊ฐ€์ง‘๋‹ˆ๋‹ค.

$$ \sum_{i=1}^{n}p_{i}(1-p_{i}) $$

  • ๋ณ€์ˆ˜์— ๋Œ€ํ•œ ์„ค๋ช…๋„ ์—”ํŠธ๋กœํ”ผ์™€ ๊ฐ™์Šต๋‹ˆ๋‹ค.
  • \(p_{i}\) = ํ˜„์žฌ Node์—์„œ ๊ฐ€์ง€๊ณ  ์žˆ๋Š” ๋ฐ์ดํ„ฐ ์ง‘ํ•ฉ์— ๋Œ€ํ•ด i-th class์˜ ๋น„์œจ์„ ๋‚˜ํƒ€๋ƒ…๋‹ˆ๋‹ค.
  • \(n\) = class์˜ ๊ฐœ์ˆ˜

ํ•จ์ˆ˜๋„ Entropy์™€ ๋น„์Šทํ•˜๊ฒŒ ์ƒ๊ฒผ๋Š”๋ฐ Geogebra๋กœ ๊ทธ๋ ค๋ณด์•˜์Šต๋‹ˆ๋‹ค. ๋งˆ์ฐฌ๊ฐ€์ง€๋กœ 0๊ณผ 1์— ๊ทผ์ ‘ํ• ์ˆ˜๋ก Impurity๊ฐ€ ๋‚ฎ์•„์ง์— ๋”ฐ๋ผ ๋ถˆํ™•์‹ค์„ฑ์ด ์ค„์–ด๋“ ๋‹ค๋Š” ํŠน์ง•์ด ์žˆ์Šต๋‹ˆ๋‹ค.


๐Ÿ“„ Information Gain

์ด๋Ÿฌํ•œ ์ฒ™๋„๋ฅผ ํ†ตํ•ด ๊ฐ ๋…ธ๋“œ์˜ ๋ฐ์ดํ„ฐ ์ง‘ํ•ฉ์— ๋Œ€ํ•œ ํด๋ž˜์Šค์˜ ๋น„์œจ์„ ํ†ตํ•ด Entropy์™€ Gini Impurity๋ฅผ ๊ตฌํ•  ์ˆ˜ ์žˆ์—ˆ์Šต๋‹ˆ๋‹ค.

๊ทธ๋Ÿผ Criterion์„ ๊ฐ€์ง€๊ณ ์„œ ๋ฌด์—‡์„ ํ†ตํ•ด Node๋ฅผ Split ํ•˜๋ƒ๋ฉด, Parent Node์˜ ๋ถˆ์ˆœ๋„์™€ Child Node(Left and Right)์˜ ๋ถˆ์ˆœ๋„ ์ฐจ์ด๋ฅผ ๊ตฌํ•ฉ๋‹ˆ๋‹ค. ์ด ์ฐจ์ด ๊ฐ’์„ Information Gain(์ •๋ณด ์ด๋“)์ด๋ผ๊ณ  ํ•ฉ๋‹ˆ๋‹ค. ์šฐ๋ฆฌ์˜ ๋ชฉํ‘œ๋Š” ์ด Information Gain์ด ์ตœ๋Œ“๊ฐ’์„ ๊ฐ–๋„๋ก ํ•˜๋Š” ๊ฒƒ์ธ๋ฐ ์ด๋Š” ์ƒ์œ„ Node์—์„œ ํ•˜์œ„ Node๋กœ Split ๋  ๋•Œ, ํ•˜์œ„ ๋…ธ๋“œ์˜ ๋ถˆ์ˆœ๋„๋ฅผ ๋งŽ์ด ์ค„์˜€๋‹ค๋Š” ๊ฒƒ๊ณผ ๊ฐ™์Šต๋‹ˆ๋‹ค. (= ํ•˜์œ„ ๋…ธ๋“œ์˜ ํด๋ž˜์Šค ๋น„์œจ์ด ์กฐ๊ธˆ ๋” ๊ทน์ ์œผ๋กœ ๋‚˜๋‰˜์—ˆ๋‹ค.)

$$ Information\,Gain =
(Parent's\,\,Impurity)
-
(\frac{N_{left}}{N_{parent}}\times(Left\,\,child's\,\,Impurity)+\frac{N_{right}}{N_{parent}}\times(Right\,\,child's\,\,Impurity)
) $$

ํ•˜์ง€๋งŒ, ์•„์ง ํ’€๋ฆฌ์ง€ ์•Š์€ ๊ถ๊ธˆ์ ์ด ๋‚จ์Šต๋‹ˆ๋‹ค.

Parent Node์™€ Child Node์˜ ๋ถˆ์ˆœ๋„๋ฅผ ๊ณ„์‚ฐํ•˜๊ธฐ ์ „์— Split์€ ๋ฌด์Šจ ๊ธฐ์ค€์œผ๋กœ ํ•œ ๊ฒƒ์ธ๊ฐ€?

-> Data์˜ Feature๋ฅผ ์ด์šฉํ•ฉ๋‹ˆ๋‹ค.

 

์—ฌ๊ธฐ์„œ ์ธ์ง€ํ•˜๊ณ  ์žˆ์–ด์•ผ ํ•  ์ ์€ ๋ฐ์ดํ„ฐ๋Š” ์—ฌ๋Ÿฌ Feature๋ฅผ ๊ฐ€์ง„๋‹ค๋Š” ๊ฒƒ์ž…๋‹ˆ๋‹ค. ์˜ˆ์‹œ๋ฅผ ๊ฐ„๋‹จํ•˜๊ฒŒ ๋“ค๊ธฐ ์œ„ํ•ด Feature์˜ ์–ธ๊ธ‰์€ ์—†์—ˆ์ง€๋งŒ, ๋ชจ๋“  Feature๋ฅผ ๊ธฐ์ค€์œผ๋กœ Split ๋˜์–ด ๋ถˆ์ˆœ๋„๋ฅผ ์ธก์ •ํ•œ ๊ฒƒ์„ ๊ธฐ๋ฐ˜์œผ๋กœ Information Gain์ด ๊ฐ€์žฅ ํฐ ๊ฐ’์„ ๊ฐ€์ง€๋Š” Feature์™€ ํ•ด๋‹น Feature์˜ ๊ธฐ์ค€ ๊ฐ’์„ Node๋ฅผ Split ํ•˜๋Š” Criterion์œผ๋กœ ์ฑ„ํƒํ•ฉ๋‹ˆ๋‹ค.

 

(์•„๋ž˜ ์˜ˆ์‹œ์—์„œ๋Š” petal width๋ผ๋Š” feature์™€ ๊ธฐ์ค€ ๊ฐ’์ด 0.75๋กœ ์ฑ„ํƒ๋˜์—ˆ์Šต๋‹ˆ๋‹ค.)

 

 

์ฆ‰, Information Gain์„ ๊ตฌํ•˜๊ธฐ ์œ„ํ•ด์„œ๋Š” ํ•œ Feature๋งˆ๋‹ค Information Gain์˜ ์ตœ๋Œ“๊ฐ’์„ ๊ฐ€์ง€๋„๋ก ํ•˜๋Š” ๊ธฐ์ค€ ๊ฐ’์„ ์ฐพ๊ณ , ๋ชจ๋“  ๊ธฐ์ค€ ๊ฐ’๋“ค๋กœ๋ถ€ํ„ฐ Information Gain์˜ ์ตœ๋Œ“๊ฐ’ ์ค‘์˜ ์ตœ๋Œ“๊ฐ’์„ ๊ตฌํ•˜๋Š” ๊ฒŒ Information Gain์„ ๊ตฌํ•˜๋Š” ๋ฐฉ๋ฒ•์ž…๋‹ˆ๋‹ค.

 

+ ์—ฌ๋Ÿฌ ์›น์—์„œ Information Gain์— ๋Œ€ํ•œ Formula๋ฅผ ์–ธ๊ธ‰ํ•  ๋•Œ, Child Node์˜ ๋ถˆ์ˆœ๋„ ํ‰๊ท ์„ ๊ตฌํ•˜๋Š”๋ฐ ํ‰๊ท ์ด ์•„๋‹Œ Split ๋œ ํ›„์— (Child Node Sample ๊ฐœ์ˆ˜)/(Parent Node Sample ๊ฐœ์ˆ˜)์˜ Proportion์„ ๊ฐ Child Node์— ๊ณฑํ•˜์—ฌ Child Node์˜ ์ „์ฒด์ ์ธ ๋ถˆ์ˆœ๋„๋กœ ์‚ฌ์šฉ๋ฉ๋‹ˆ๋‹ค.

 

์ด์ œ ์œ„์˜ Decision Tree๋ฅผ ๋‹ค์‹œ ๋ณด๋ฉด ์ด๋Ÿฐ ํ•ด์„์ด ๊ฐ€๋Šฅํ•ฉ๋‹ˆ๋‹ค.

  1. Gini Impurity๋ฅผ ํ†ตํ•ด Root Node์˜ ๋ถˆ์ˆœ๋„๋ฅผ ํ™•์ธํ•˜์˜€๋‹ค. -> 0.687
  2. ์ด Gini Impurity๋Š” (35/105)(1 - 35/105) * 3 = 0.667์ด ๋งž๋‹ค.
  3. ํ˜„์žฌ ์—ฌ๊ธฐ์„œ ๋ฐœ์ƒํ•˜๋Š” Information Gain์€ 0.667 - ((35/105)*0.0 + (70/105)*0.5) = 0.334์ด๋‹ค.
  4. 0.334๋ผ๋Š” ๊ฐ€์žฅ ํฐ Information Gain์ด ๋งŒ๋“ค์–ด์ง€๊ฒŒ ๋œ Feature๋Š” 'petal width'์™€ ๊ธฐ์ค€ ๊ฐ’์€ 0.75์ด๋‹ค.

๐Ÿ“„ Entropy์™€ Gini Impurity์˜ ์ฐจ์ด

๊ทธ๋ ‡๋‹ค๋ฉด, Entropy์™€ Gini Impurity๋Š” ๋‘˜ ๋‹ค ๋…ธ๋“œ์˜ ๋ถˆ์ˆœ๋„๋ฅผ ์ธก์ •ํ•˜๋Š” ๊ณตํ†ต์ ์ด ์žˆ๋Š”๋ฐ ๊ตฌํ•˜๋Š” ๋ฐฉ๋ฒ•์ด ๋‹ค๋ฅธ ๊ฑฐ ์™ธ์—๋Š” ์ฐจ์ด์ ์ด ๋ณด์ด์ง€ ์•Š์Šต๋‹ˆ๋‹ค. ํ•˜์ง€๋งŒ, Entropy๊ฐ€ log๋ฅผ ์‚ฌ์šฉํ•จ์œผ๋กœ์จ ์ƒ๊ธฐ๋Š” ๋ฏธ๋ฌ˜ํ•œ ์ฐจ์ด๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค.

  1. Entropy๋Š” ์กฐ๊ธˆ ๋” ๋ฏธ์„ธํ•œ ์ฐจ์ด๋ฅผ ๊ฐ์ง€ํ•œ๋‹ค. -> ๋กœ๊ทธ ํ•จ์ˆ˜๋ฅผ ์‚ฌ์šฉํ•˜๊ธฐ ๋•Œ๋ฌธ์— Gini Impurity๋ณด๋‹ค ๋ฏธ์„ธํ•œ ์ฐจ์ด๋ฅผ ๊ฐ์ง€ํ•˜์—ฌ ๋…ธ๋“œ์˜ ์ˆœ์ˆ˜์„ฑ์„ ์ •ํ™•ํ•˜๊ฒŒ ํ‰๊ฐ€ํ•  ์ˆ˜ ์žˆ๋‹ค. ๋˜ํ•œ, ๋ถˆ๊ท ํ˜•ํ•œ ๋ฐ์ดํ„ฐ์…‹์—๋„ Gini๋ณด๋‹ค๋Š” Entropy๊ฐ€ ๋” ์ข‹์€ ํšจ๊ณผ๋ฅผ ๋ณด์ธ๋‹ค.
  2. Gini Impurity๋Š” Entropy์— ๋น„ํ•ด ์ƒ๋Œ€์ ์œผ๋กœ ๊ฐ„๊ฒฐํ•˜๋‹ค. -> Entropy๋ณด๋‹ค ๊ฐ„๊ฒฐํ•˜๋‹ค๋Š” ๊ฒƒ์€ Entropy๊ฐ€ ์ ์šฉ๋˜์–ด๋„ ๋  ๋ฌธ์ œ์— Gini Impurity๋ฅผ ์ ์šฉํ•จ์œผ๋กœ์จ ๊ฐ„๊ฒฐํ•˜๊ณ  ๋” ๋น ๋ฅด๊ณ , ์ง๊ด€์ ์œผ๋กœ ๋ถˆ์ˆœ๋„๋ฅผ ์ฒ˜๋ฆฌํ•  ์ˆ˜ ์žˆ๋‹ค. ๊ทธ๋ž˜์„œ ์ผ๋ฐ˜์ ์œผ๋กœ Gini Impurity๋ฅผ Binary Classification ๋ฌธ์ œ, Entropy๋ฅผ Mulit Classification ๋ฌธ์ œ์— ์ ์šฉ์ด ๋˜๋Š” ๊ฒŒ ์ผ๋ฐ˜ํ™”๋˜์–ด๊ฐ€๊ณ  ์žˆ๋‹ค.

 

728x90