2080 2

CSC420 Ā· 2080 Ā· 10 marks

How Classification Differs from Regression. Train ID3 Classifier

How Classification Differs from Regression. Train ID3 Classifier

Data Warehousing and Data MiningChapter 6: Classification and PredictionID3 as attribute selection algorithmNumerical: ID3 decision tree

Classification vs Regression and ID3 Decision Tree

Part 1: Classification vs Regression

AspectClassificationRegression
OutputDiscrete class label (e.g. Up/Down)Continuous numeric value
GoalAssign a tuple to a predefined categoryPredict a numeric quantity
ExampleLoan = "safe"/"risky"Predicting house price
AlgorithmsID3, Naive Bayes, KNNLinear/Polynomial Regression
EvaluationAccuracy, Precision, RecallRMSE, MAE

Classification predicts a discrete categorical label; regression predicts a continuous ordered value.


Part 2: ID3 Classifier

Given data

9 tuples: Class Up = 5, Down = 4.

Step 1: Entropy of dataset

$$E(D) = -\tfrac{5}{9}\log_2\tfrac{5}{9} - \tfrac{4}{9}\log_2\tfrac{4}{9} = 0.4711 + 0.5200 = 0.9911$$

Step 2: Information Gain

Age: old(3): 0Up,3Down; mid(3): 2Up,1Down; new(3): 3Up,0Down

$$E(\text{old})=0,\quad E(\text{new})=0$$ $$E(\text{mid}) = -\tfrac{2}{3}\log_2\tfrac{2}{3}-\tfrac{1}{3}\log_2\tfrac{1}{3}=0.9183$$ $$E_{\text{Age}} = \tfrac{3}{9}(0)+\tfrac{3}{9}(0.9183)+\tfrac{3}{9}(0)=0.3061$$ $$\text{Gain(Age)} = 0.9911 - 0.3061 = 0.6850$$

Competition: Yes(4): 2Up,2Down; No(5): 3Up,2Down

$$E(\text{Yes})=1.0,\quad E(\text{No})=0.9710$$ $$E_{\text{Comp}} = \tfrac{4}{9}(1.0)+\tfrac{5}{9}(0.9710)=0.9838$$ $$\text{Gain(Competition)} = 0.9911-0.9838 = 0.0073$$

Type: SW(5): 2Up,3Down; HW(4): 3Up,1Down

$$E(\text{SW})=0.9710,\quad E(\text{HW})=0.8113$$ $$E_{\text{Type}} = \tfrac{5}{9}(0.9710)+\tfrac{4}{9}(0.8113)=0.5394+0.3606=0.9000$$ $$\text{Gain(Type)} = 0.9911-0.9000 = 0.0911$$

Root = Age (highest gain 0.6850).

Step 3: Split on Age

  • Age = old → all Down → leaf Down
  • Age = new → all Up → leaf Up
  • Age = mid → mixed, needs further split.

Step 4: Subtree for Age = mid

CompetitionTypeProfit
YesSWDown
NoHWUp
YesHWUp

Subset: 3 tuples (2 Up, 1 Down). $$E(D_{mid}) = -\tfrac{2}{3}\log_2\tfrac{2}{3}-\tfrac{1}{3}\log_2\tfrac{1}{3}=0.9183$$

Competition: Yes(2): 1Up,1Down → E=1.0; No(1): 1Up → E=0 $$E_{\text{Comp}} = \tfrac{2}{3}(1.0)+\tfrac{1}{3}(0)=0.6667$$ $$\text{Gain} = 0.9183-0.6667 = 0.2516$$

Type: SW(1): 0Up,1Down → E=0; HW(2): 2Up → E=0 $$E_{\text{Type}} = 0 \Rightarrow \text{Gain} = 0.9183 ;(\text{maximum})$$

Split on Type:

  • Type = SW → Down
  • Type = HW → Up

Final Decision Tree

Age?
ā”œā”€ā”€ old  → Down
ā”œā”€ā”€ new  → Up
└── mid  → Type?
            ā”œā”€ā”€ SW → Down
            └── HW → Up

Step 5: Prediction for [Age = Mid, Competition = Yes, Type = HW]

Age = mid → check Type → Type = HW → Up

$$\boxed{\text{Predicted Profit = Up}}$$

Short on time? The 1, 5 and 10 mark versions of this answer, flashcards and practice sets come with a program pass.