CSE4261 Lecture-10
CSE4261 Lecture-10
Methods: Classification
Regression
Regression
E=1-P(m==k)
General Algorithm
Example
There are 26x32x42=9,216 possible combinations of values for the
input attributes. But we are given the correct output for only 12 of
them; each of the other 9,204 could be either true or false; we don’t
know.
Objective: find the smallest tree that is consistent with
the inputted data set
-(2/5(-0.5log(0.5)-0.5log(0.5))=-0.4) = .570
Attribute Selection Measure 2: Gain Ratio
Super attributes: Such an attribute will split into as many partitions as the number of
values and each partition would be impure i.e. information gain would be highest and entropy
would be zero which is not good for training a machine learning model. It would lead to
overfitting the model.
Example: Gain Ratio
Attribute Selection Measure 3: Gini Index
• FN: The False-negative value for a class will be the sum of values of corresponding rows
except for the TP value.
• FP: The False-positive value for a class will be the sum of values of the corresponding column
except for the TP value.
• TN: The True-negative value for a class will be the sum of the values of all columns and rows
except the values of that class that we are calculating the values for.
• TP: The True-positive value is where the actual value and predicted value are the same.
Confusion Matrix-Multi-Class Classification
The x-axis defines the model’s expected values, and the y-axis defines the actual values. The
10x12(MxN) matrix structure was used to build this matrix. According to our model, some
images have numerous objects detected while others have no objects detected at all. As a
result, the matrix has two additional columns labeled Multiple obj detection and No Object
Detection, respectively.
In the figure, the number of nonobject detection images is zero, but four images are identified
as multiples of person for Person2, Person3, Person6, and Person10.
Confusion Matrix-Multi-Class Classification
• Precision: measures the model's ability to identify
instances of a particular class correctly.
40
Tree induction example
Entropy of data S
Info(S) = -9/14(log2(9/14))-
(9/14))-5/14(log2(5/14)) = 0.94
41
Tree induction example
Split data by attribute Temperature
S[9+, 5-5-] <15 [3+,1-
[3+,1-]
Temperature 15-
15-25 [4+,2-
[4+,2-]
>25 [2+,2-
[2+,2-]
42
Tree induction example
Split data by attribute Humidity
High [3+,4-
[3+,4-]
S[9+, 5-
5-] Humidity
Normal [6+, 1-
1-]
Gain(Humidity) = 0.94 – 7/14[-
7/14[-3/7(log2(3/7))-
(3/7))-4/7(log2(4/7))]
– 7/14[-
7/14[-6/7(log2(6/7))-
(6/7))-1/7(log2(1/7))]
= 0.94 – 0.79 = 0.15
Split data by attribute Wind
Weak [6+, 2-
2 -]
S[9+, 5-
5-] Wind
Strong [3+, 3-
3 -]
Gain(Wind) = 0.94 – 8/14[-
8/14[-6/8(log2(6/8))-
(6/8))-2/8(log2(2/8))]
– 6/14[-
6/14[-3/6(log2(3/6))-
(3/6))-3/6(log2(3/6))]
= 0.94 – 0.89 = 0.05
43
Tree induction example
Rain 15-
15-25 High Strong No
44
Entropy of branch Sunny
Info(Sunny) = -2/5(log2(2/5))-
(2/5))-3/5(log2(3/5)) = 0.97
45
Tree induction example
Outlook
Humidity Yes ??
High Normal
No Yes
46
Entropy of branch Rain
Info(Rain) = -3/5(log2(3/5))-
(3/5))-2/5(log2(2/5)) = 0.97
47
Tree induction example
Outlook
No Yes Yes No
48
Example: Gini Index
Gini index for the root node for Student
Background attribute.
The overall Gini Index for this split with the online variable