Académique Documents
Professionnel Documents
Culture Documents
1 #
Evaluation of a Classifier
Natural performance measure for classification problems: error rate on a test set
Success: instances class is predicted correctly Error: instances class is predicted incorrectly Error rate: proportion of errors made over the whole set of instances Accuracy: proportion of correctly classified instances over the whole set of instances accuracy = 1 error rate
Evaluation of a Classifier
e.g. prunning rules for the rare class can be difficult, resulting in rules involving large number of attributes and low coverage (overfitting)
Confusion Matrix
PREDICTED CLASS
Class=Yes Class=No b d
a: TP (true positive) b: FN (false negative) c: FP (false positive) d: TN (true negative)
Class=Yes
a c
Other Metrics
PREDICTED CLASS
Class=Yes Class=No
a: TP (true positive)
Class=Yes
a c
b d
Precision (p) =
TP TP + FP
F-measure (F) =
2rp r+p
Recall (r) =
TP = TPR TP + FN
Accuracy: high
TNs
+ + FNs
+ -
Sensitivity (TPR): high Good at classifying records of class +, i.e. few FNs Specificity (TNR): high Good at classifying records of class , i.e. few FPs
- --
FP
#
+ + - + ++ + + + + + + - + + + +
Classifier decision boundaries
+ +
FPs
+ +
Sensitivity (TPR): 100% Good at classifying records of class +, i.e. zero FNs Specificity (TNR): 0% Classifies correctly half of the - records
#
+ + - + ++ + + + + + + - + + + +
Classifier decision boundaries
Accuracy: high
TPs
+ TNs FPs
+ +
Sensitivity (TPR): 100% Good at classifying records of class +, i.e. zero FNs Specificity (TNR): 50% Bad at classifying records of class , FPR = 50%
#
Accuracy: very high Sensitivity (TPR): 100% Good at classifying records of class +, i.e. zero FNs Specificity (TNR): very high Good at classifying records of class -, i.e. few FPs
+ + + + + + +
TPs FPs
TNs
Bad classifier: about half of the documents classified as being about X have nothing to do with X
#
Recall (TPR) =
+ + + + + + +
TPs FPs
TNs
Accuracy: very high Recall (TPR): 100% Good at classifying records of class +, i.e. zero FNs Precision: 50% (low) Too many FPs compared to the TPs
#
FNs = 0
TNM033: Introduction to Data Mining
- + + + + + + + + ++ + - + + ++ + +
Classifier decision boundaries
Recall (TPR) =
- - - TNs FNs
+ +
TPs
Accuracy: very high Recall (TPR): very high Good at classifying records of class +, i.e. few FNs Precision: 100% No FPs
Classification Costs
How to build a classifier that takes into account the misclassification costs?
+ + + + -
+ + + ++ + + + + + +
Cost Matrix
PREDICTED CLASS C(i|j) ACTUAL CLASS Class=No
Class=Yes Class=Yes C(Yes|Yes) C(Yes|No) Class=No C(No|Yes) C(No|No)
C(i|j): Cost of misclassifying class j example as class i How to use the cost matrix?
Cost-sensitive evaluation of classifiers (average cost of the model) Cost-sensitive classification Cost-sensitive learning
TNM033: Introduction to Data Mining #
Cost-sensitive Evaluation
Cost Matrix ACTUAL CLASS PREDICTED CLASS C(i|j)
+ -1 1
Model M2
100 0
PREDICTED CLASS
+ -
Model M1
PREDICTED CLASS
+
ACTUAL CLASS
40 250
ACTUAL CLASS
+ + 250 5
45 200
+ -
150 60
Cost-sensitive Learning
- ++ + + ++ ++ + + + + + + + + ++ - + + + + + + + + + + - + + ++ + + + + -+ +++ -
Classifiers tend to be biased to the majority class Highly specialized patterns susceptible to the presence of noise Accuracy (error rate) measure can be misleading
Cost-sensitive learning
C(- | +) > C(+ | -) (cost of FN higher than cost of FP) Use MetaCost algorithm
Oversampling
- ++ + + + + + + + + + + + ++ + + + - + + + + + + + + + + - + + ++ + + + + -+ + ++ -
Undersampling
+ + +
+ + + ++ + + + + + + -
Weka: Sampling
Preprocess
Supervised
Instance Resample NoReplacement = false biasToUniform = 1 spreadSubSample distributionSpread = 1 (undersamples the majority class)
Undersamples the majority class and oversamples the rare class