1. Basic Concepts
โ Definition
โข Classification task

โข Given a collection of records (training set), we find a model for the class attribute as a function of the values of other attributes. Each record contains a set of attributes, and one of the attributes is the class.
โข Previously unseen records (test set) should be assigned a class as accurately as possible
โช A test set is used to determine the accuracy of the model. Usually, the given data set is divided into training and test sets, with the training set used to build the model and the test set used to validate it
โก Example
โข Predicting tumor cells as benign or malignant (์ข ์ ์์ฑ์์ฑ)
โข Classifying credit card transactions as legitimate or fraudulent (์ฌ๊ธฐ๊ฑฐ๋ํ์ง)
โข Classifying secondary structures of protein as alpha-helix, beta-sheet, or random coil
โข Categorizing news stories as finance, weather, entertainment, sports, etc
โข techniques

2. Decision Tree Induction
โ Example
โข All the leaf node have a single same label

โข There could be more than one tree that fits the same data

โก Decision tree classification
โข Train, test dataset



โข Tree Induction: Greedy strategy
โช Split the records based on an attribute test that optimizes certain criterion (gini index, gain ratio...)
โช ๋ฐ์ดํฐ๋ฅผ split ํ๋ ๋ฐฉ๋ฒ
(1) attribute ์ ๋ํด condition ์ ์ด๋ป๊ฒ ๊ตฌ์ฒดํ ํ ๊น (test ์กฐ๊ฑด์ ์ด๋ป๊ฒ ์ค์ ํ ๊น)
(2) best split ์ ์ด๋ป๊ฒ ๊ฒฐ์ ํ ๊น, ์ธ์ split ์ ๋ฉ์ถ๊น
โข How to Specify Test Condition
โข How to Specify Test Condition
โช (1) Depend on attributes types : nominal, ordinal, continuous
โช (2) Depends on number of ways to split : 2-way split, multi-way split
A. Splitting based on nominal attributes
โช Multi-way split : use as many partitions as distinct values

โช Binary split: Divide values into two subsets, need to find optimal partitioning

B. Splitting based on Ordinal attributes
โช Multi-way split : Use as many partitions as distinct values

โช Binary split: Divide values into two subsets; need to find optimal partitioning

Ordinal attributes ์์ binary split ์ ํ ๋, ์๋์ ๊ฐ์ด ๋๋๋ ๊ฒ์ ์ ์ ํ์ง ์๋ค. {Small, Large} ๋ consecutive ํ ๊ฐ์ด ์๋๊ธฐ ๋๋ฌธ์ด๋ค. ๊ฐ branch ์ child node ๋ ์๋ฏธ์๋ combination ์ด์ฌ์ผ ํ๋ค.

C. Splitting based on Continuous attributes
Binary split ์ ๊ฒฝ์ฐ์๋, ๊ฐ์ฅ ๋ถ๋ฅ๋ฅผ ์ ํ ์ ์๋ best cut point ๋ฅผ ์ฐพ๋ ๊ฒ์ด ์ค์ํ๊ณ , Multiway split ์ ๊ฒฝ์ฐ์๋ discretization (์ด์ฐํ, ๊ตฌ๊ฐํ) ๋ฅผ ์ ์ํํด์ผ ํ๋ค.

โฃ How to Determine the Best Split
โข How to Determine the Best Split

โช ์ด๋ค test condition ์ด ์ต์ ์ผ๊น
โช greedy ์ ๊ทผ์ ์ฌ์ฉํ ๋, homogeneous class distribution ์ ๊ฐ์ง ๋ ธ๋๋ฅผ ๊ธฐ์ค์ผ๋ก ํธ๋ฆฌ๋ฅผ ํ์ฑํ๋ ๊ฒ์ด ์ข๋ค.

โช Non-Homogeneous = high degree of impurity
โช Homogeneous = low degree of impurity
โข Example

โช M0 : split ์ ์ ๋ ธ๋ ๋ถ์๋ , M12 : A ๋ณ์๋ฅผ ๊ธฐ์ค์ผ๋ก split ํ ํ์ ๋ ธ๋ ๋ถ์๋, M34 : B ๋ณ์๋ฅผ ๊ธฐ์ค์ผ๋ก split ํ ํ์ ๋ ธ๋ ๋ถ์๋
โช Gain = M0 - M12 vs M0 - M34 โจ (M0-M12) ๊ฐ ํฌ๋ฉด A๋ฅผ ์ ํ, (M0-M34) ๊ฐ ๋ ํฌ๋ฉด B๋ฅผ ์ ํ
3. GINI Index (CART)
โ Measure of Impurity : GINI
โข ์ฃผ์ด์ง ๋ ธ๋ t ์์ ์ง๋๊ณ์ ๊ตฌํ๊ธฐ

โจ P(j | t) = ๋ ธ๋ t์์ class j ์ ์๋๋น๋
โจ ์ง๋๊ณ์์ ๊ฐ์ด ์์์๋ก ์ข๋ค.
โจ ์ง๋๊ณ์ ์ต๋๊ฐ = 1 - 1/nc , nc = # of records : ๋ชจ๋ records ๊ฐ ๋ชจ๋ class ์ ๋๋ฑํ๊ฒ ๋ถํฌ๋์์ ๋๋ฅผ ์๋ฏธํ๋ค. ์ด๋ interesting information ์ least ํ ์ํ์ด๋ค. (์ป์ ์ ์๋ ์ ๋ณด๊ฐ ์๋ ์ต์ ์ case). P(j | t) = 1/nc ๋ผ๊ณ ๋ณผ ์ ์๋ค.
โจ ์ง๋๊ณ์ ์ต์๊ฐ = 0.0 : ๋ชจ๋ recoreds ๊ฐ ํ๋์ class ๋ก๋ง ํ ๋น๋ ์ํ๋ฅผ ์๋ฏธํ๋ค. ์ด๋ interesting information ์ most ํ ์ํ์ด๋ค. (์ป์ ์ ์๋ ์ ๋ณด๊ฐ ๋ง์ case)
โข Example

โข ์ง๋๊ณ์๋ฅผ ๊ธฐ์ค์ผ๋ก split ํ๋ ๋ฐฉ๋ฒ
โช Used in CART (Classification and Regression Tree), SLIQ, SPRINT
โช ๋ ธ๋ p ๋ฅผ k ์ partition (children) ์ผ๋ก ์ชผ๊ฐ๊ณ ์ ํ ๋, split ์ quality ๋ฅผ ์ธก์ ํ๋ ๋ฐฉ๋ฒ์ ์๋์ ๊ฐ๋ค.

โช child i ์์์ record ์ ๊ฐฏ์๋ฅผ ni, node p ์์์ record ์ ๊ฐฏ์๋ฅผ n ์ด๋ผ๊ณ ํ ๋, ๊ฐ child node ์ ๋ํด ์ง๋๊ณ์๋ฅผ ๊ณ์ฐํ๊ณ weighted sum ์ ํ๋ค.
โก Attributes
โข Binary
โช two partition ์ผ๋ก ๋ถ๋ฅ
โช Larger and purer partitions are sought for

โข Categorical
โช For each distinct value, we gather counts for each class in the dataset and use the count matrix to make decisions

โข Continuous
โช Several choices for the splitting value v

โช ๊ฐ๋ฅํ splitting values ์ ๊ฐ์ = distinct values ์ ๊ฐ์

โช ์ต์ ์ v ๋ฅผ ์ ํํ๋ ๋ฐฉ๋ฒ : ๊ฐ v ๊ฐ์ ๋ํด ๋ฐ์ดํฐ๋ฒ ์ด์ค๋ฅผ ์ค์บํ๋ค. count matrix ๋ฅผ ์ค๊ณํ๊ณ ์ง๋๊ณ์๋ฅผ ๊ณ์ฐํ๋ค โ ๊ทธ๋ฌ๋ ์ผ์ผํ ๊ณ์ฐํ๋ ๊ฒ์ ๊ณ์ฐ์ ์ผ๋ก ๋นํจ์จ์ ์ด๋ค.

โช ํจ์จ์ ์ผ๋ก ๊ณ์ฐํ๋ ๋ฐฉ๋ฒ : ๊ฐ attribute ์ ๋ํด, value ๋ฅผ ์ ๋ ฌํ๊ณ , ์ ํ์ ์ผ๋ก ์ด value ๋ค์ ์ค์บํ์ฌ, ๊ฐ time ๋ง๋ค count matrix ์ ์ง๋๊ณ์๋ฅผ ์ ๋ฐ์ดํธํ๋ค. ๊ฐ์ฅ ์ต์์ ์ง๋๊ณ์ ๊ฐ์ ๊ฐ์ง๋ ์์น๋ฅผ ๊ธฐ์ค์ผ๋ก split ์ ํ๋ค.
์๋ฅผ๋ค์ด ์ฒ์ ๋ฐ์ดํฐํ๋ ์์์ Taxable income ๋ณ์๋ continous ๋ณ์์ ํด๋นํ๋ฏ๋ก ์์ ๋ฐฉ๋ฒ์ฒ๋ผ best split position ์ ์ฐพ์๋ณผ ์ ์๋ค. ์ผ๋จ taxable income ๋ณ์ ๊ฐ๋ค์ ์ ๋ ฌํ ํ์, ๊ฐ ๊ฐ๋ค์ ์ค๊ฐ ๊ฐ์ split position ์ผ๋ก ์ก๋๋ค. ํด๋น ์ค๊ฐ ๊ฐ์ ๊ธฐ์ค์ผ๋ก ์ด๊ณผ, ์ดํ๋ก split ์ ์ก์ ํ์, ๊ฐ split position ์ ๊ธฐ์ค์ผ๋ก ์ง๋๊ณ์๋ฅผ ๊ณ์ฐํ๋ค. cheat ๋ณ์์ ๋ ์ด๋ธ์ ๊ธฐ์ค์ผ๋ก Yes, No ์ ํ ๋นํ๋ ๊ฒฝ์ฐ์ ์๋ฅผ ์ฝ๊ฒ ๊ณ์ฐํด๋ณผ ์ ์๋ค. (์ง์ ํด๋ณด๊ธฐ)
โข Drawback of the Gini Index
โข ์ง๋๊ณ์์ ํ๊ณ์
A. Bias towards equally-sized subsets

โข greedy ํ ๋ฐฉ์์ผ๋ก ๋์ํ๊ธฐ ๋๋ฌธ์, ์ดํ์ efficient ๋ ๊ณ ๋ คํ์ง ์๊ณ , ํด๋น step ์์ ๊ฐ์ฅ ์ต์ ์ ์ ํํ๋ค. ๋ฐ๋ผ์ ์์ ๊ทธ๋ฆผ์์ x6 ์ด ์ข ๋ balance ๋๊ฒ ๋๋์ด์ ์ผ์ชฝ ๋ถ๋ฅ๋ฅผ ์ต์ข ์ ์ผ๋ก ์ ํํ๊ฒ ๋๋ค. ๊ทธ๋ฌ๋ x1 ์ด ์ดํ ๋ถ๋ฅ์์ ์ข ๋ homogeneous ํ๊ฒ (balance ๋๊ฒ) ๋๋ ์ ธ ์ต์ข ๋ถ์๋์ ๊ฒฐ๊ณผ๋ x1 ์ด ๋ ์ข๋ค.
โข pure offspring
์ด 7๊ฐ์ class ๊ฐ ์กด์ฌํ ๋, class1 ๊ณผ class2 ์ ์ํด ๋ฐ์ดํฐ์ ์ด ๋๋์ด์ง๋ค๊ณ ํ๋ค๋ฉด
- option 1 : class1 ๊ณผ 2๋ก ๊ฐ๋ฅํ ๋นจ๋ฆฌ ๋ถ๋ฆฌ โจ favored
- option 2 : (class1,2) ์ ๋ค๋ฅธ class ๋ค๋ก ๋ถ๋ฆฌ โจ could be better : ์ต์ข ์ ์ธ ๊ฒฐ๊ณผ์์๋ ๋ ์ข๊ฒ ์ง๋ง, class1 ๊ณผ 2๊ฐ ์์ฌ ์๋ ๊ฒ์ pure ํ์ง ์๊ธฐ ๋๋ฌธ์ ์ ํธํ์ง ์์
โฃ Algorithm CART
1. ๊ฐ attribute์ best split ์ ์ฐพ๋๋ค : ๋ ธ๋๊ฐ ๋ถ๋ฆฌ๋ ๋ ์ง๋๊ณ์๋ฅผ ๋ฎ์ถ๋ point ๊ฐ best split point ์ด๋ค.
2. node ์ best split ์ ์ฐพ๋๋ค : step1 ์์ ์ฐพ์ best split ๊ฐ๋ค ์ค์ ์ง๋ ๊ณ์๊ฐ ๊ฐ์ฅ ๋ฎ์ ๊ฒ์ ์ ํํ๋ค.
3. stopping rule ์ด ๋ง์กฑ๋์ง ์์ ๋๊น์ง step2 ๋ฅผ ๋ฐ๋ณตํ๋ค.
'1๏ธโฃ AIโขDS > ๐ ๋จธ์ ๋ฌ๋' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
Uplift modeling (0) | 2023.06.06 |
---|---|
๋ฐ์ดํฐ๋ง์ด๋ Association analysis (0) | 2023.03.29 |
๋ฐ์ดํฐ๋ง์ด๋ Preprocessing โข (0) | 2023.03.29 |
๋ฐ์ดํฐ๋ง์ด๋ Preprocessing โก (0) | 2023.03.15 |
๋ฐ์ดํฐ๋ง์ด๋ Preprocessing โ (1) | 2023.03.15 |
๋๊ธ