Summary
In this blog spot I'm presenting a few performance measures for machine learning tasks. These performance measures come up a lot in the marketing domain.Take at home lessons:
- the measure you optimize to makes a difference
- the measure you report makes a difference
- use measure appropriate for problem/community
- accuracy often is not sufficient/appropriate
- only accuracy generalizes to >2 classes
- this is not an exhaustive list of performance measures
Confusion Matrix
First we construct a confusion matrix for a binary classification problem. Given a classification function f(x)->R and a threshold T that can split the outcomes into {0, 1} we can create a confusion matrix that counts the occurrences of the predicted class given the true label.Accuracy
Accuracy is then measured as the percentage of correct responses (True Positives + True Negatives) over the total amount of responses.Problems with Accuracy
This measure is commonly used but it can be misleading. The problems arise from the domain we are modelling. If one of the class for example is poorly represented into the metric is meaningless as we could predict the same class always and still have a good results.• Assumes equal cost for both kinds of errors
- cost(b-type-error) = cost (c-type-error)
- can be excellent, good, mediocre, poor, terrible
- depends on problem
Weighted (Cost sensitive) Accuracy
A modified version of accuracy is "Weighted Accuracy" were we count the cost of misclassification.In this scenario we aiming for a model and a threshold that can minimize the total cost.
Lift
If we are not interested in the accuracy on the entire dataset but want accurate predictions for 5%, 10% or 20% of the dataset then we can use the lift measure.Lift measures how much better than random prediction on the fraction of the dataset predicted true (f(x) > threshold).
Precision / Recall
- The Precision measure counts how many of the interest class are correct.
- The Recall measure counts how many of the interest class does the model return.
We can change the sweep over the threshold calculate Precision/Recall multiple times and graph out what is called the Precision/Recall curve.
At each different threshold we can see a different tradeoff between the two metrics.
- When the threshold is too high then c (everything is predicted as class 0) becomes zero and then the precision becomes zero.
- When the threshold is too low then b (everything is predicted as class 1) becomes zero and then the recall becomes zero.
F-Measure
The F-Measure is an attempt to merge the two measures to construct a more meaningful performance measure.Receiver Operating Characteristic (ROC)
• Developed in WWII to statistically model false positive and false negative detections of radar operators
• Better statistical foundations than most other measures
• Standard measure in medicine and biology
• Becoming more popular in ML
Although ROC graphs are apparently simple, there are some common misconceptions and pitfalls when using them in practice.
One of the earliest adopters of ROC graphs in machine learning was Spackman (1989), who demonstrated the value of ROC curves in evaluating and comparing algorithms.
ROC graphs are conceptually simple, but there are some non-obvious complexities that arise when they are used in research.
• Better statistical foundations than most other measures
• Standard measure in medicine and biology
• Becoming more popular in ML
Although ROC graphs are apparently simple, there are some common misconceptions and pitfalls when using them in practice.
One of the earliest adopters of ROC graphs in machine learning was Spackman (1989), who demonstrated the value of ROC curves in evaluating and comparing algorithms.
ROC graphs are conceptually simple, but there are some non-obvious complexities that arise when they are used in research.
ROC Plot
• Sweep threshold and plot
- TPR vs. FPR
- Sensitivity vs. 1-Specificity
- P(true|true) vs. P(true|false)
• Sensitivity = a/(a+b) = Recall = LIFT numerator
• 1 - Specificity = 1 - d/(c+d)
A ROC graph depicts relative trade-offs between benefits (true positives) and costs (false positives).
• 1 - Specificity = 1 - d/(c+d)
A ROC graph depicts relative trade-offs between benefits (true positives) and costs (false positives).
- The lower left point (0,0) represents the strategy of never issuing a positive classiffication.
- The opposite strategy is represented by the upper right point (1,1).
- The point (0,1) represents perfect classiffication.
- The diagonal line y = x represents the strategy of randomly guessing a class.
- A random classifier will produce an ROC point that "slides" back and forth on the diagonal based on the frequency with which it guesses the positive class. In order to get away from this diagonal into the upper triangular region, the classifier must exploit some information in the data.
- Any classifier that appears in the lower right triangle performs worse than random guessing. This triangle is therefore usually empty in ROC graphs.
- ROC curves have an attractive property: they are insensitive to changes in class distribution.
- Any performance metric that uses values from both columns of theconfusion matrix will be inherently sensitive to class skews. Metrics such as accuracy, precision, lift and F scores use values from both
columns of the confusion matrix. - ROC graphs are based upon TP rate and FP rate, in which each dimension is a strict columnar ratio, so do not depend on class distributions.