A10-Model-Performance-v2-2up
A10-Model-Performance-v2-2up
5-fold
cross-validation
class 1
21 (TN) 6 (FN)
negative
predicted
class
class 2
7 (FP) 41 (TP)
positive
https://en.wikipedia.org/wiki/Confusion_matrix
© Mehul Motani Model Performance 8
Recall, Specificity, and Precision
Recall and Specificity Recall and Precision
• Recall à True positive rate • Recall à True positive rate
• Specificity à True negative rate • Precision à Positive predictive value
• Are useful when false positives and • ‘stupid’ methods can achieve large
false negatives have different recall at the expense of low precision
consequences (and vice versa)
• ‘stupid’ methods can achieve large • Which one is more important
recall at the expense of low specificity depends upon application
(and vice versa) • Recall is important when false
• Which one is more important depends negatives are catastrophic and you
upon application want detect all positive cases.
• Recall is important when false • Precision in important when being
negatives are catastrophic (e.g., right (positive prediction is correct)
missed cancer detection) outweighs detecting all positives.
• Specificity is important when false • F1-Score is the harmonic mean of
positives are bad (e.g., identifying the precision and recall (used when both
wrong person in a DNA test) are important).
© Mehul Motani Model Performance 9
P P P P P P
P N N P P P
N N P P N P
N N P N N P
Algorithm 2
Accuracy = (TP+TN) /(TP+TN+FP+FN) = 6 / 12 = 0.5
P =4 N =1 Recall = TP / (TP + FN) = 4 / 5 = 0.8
Specificity = TN / (TN + FP) = 2 / 7 = 0.29
P =5 N =2 Precision = TP / (TP + FP) = 4 / 9 = 0.44
Precision
Random Random
classifier classifier
- https://scikit-learn.org/stable/modules/generated/sklearn.metrics.roc_curve.html
- https://scikit-learn.org/stable/modules/generated/sklearn.metrics.precision_recall_curve.html
- How to Use ROC Curves and Precision-Recall Curves for Classification in Python:
https://machinelearningmastery.com/roc-curves-and-precision-recall-curves-for-classification-in-
python/
optimal fit
Model Complexity
Causes of Overfitting
Underfitting Overfitting
High Bias
We want to reduce
Low Accuracy both bias and
variance!
Bias-Variance Tradeoff