Judge how well a machine learning algorithm fits
The idea
A classification model is judged on a confusion matrix of true and false positives and negatives. Precision, TP ÷ (TP + FP), matters when false positives are costly. Recall, or sensitivity, TP ÷ (TP + FN), matters when missing a positive is costly. Accuracy, (TP + TN) ÷ all observations, can mislead when classes are unbalanced. The F1 score, 2 × precision × recall ÷ (precision + recall), balances the two and suits unbalanced data. A receiver operating characteristic curve plots the true positive rate against the false positive rate across thresholds; a larger area under the curve generally means a better model. For continuous targets, root mean squared error is the usual measure.
Formulas
Precision and recall
precision = TP ÷ (TP + FP); recall = TP ÷ (TP + FN)
- precision
- the share of flagged cases that were right
- recall
- the share of real cases that were found
- TP
- true positives
- FP
- false positives
- FN
- false negatives
Precision asks how many flagged cases were right, recall how many real cases were found. Choose by which error costs more.
Accuracy and F1 score
accuracy = (TP + TN) ÷ (TP + TN + FP + FN); F1 = 2 × P × R ÷ (P + R)
- accuracy
- the share of all cases classified correctly
- F1
- the balance of precision and recall
- TP
- true positives
- TN
- true negatives
- FP
- false positives
- FN
- false negatives
- P
- precision
- R
- recall
Accuracy misleads when one class is rare. F1 balances precision and recall.
RMSE of a forecast
RMSE = √(SSE ÷ n)
- RMSE
- the root mean squared error
- SSE
- each forecast error squared, then added up
- n
- the number of forecasts
The typical size of the error, in the units of the target.
In the app: 5 practice questions on this outcome, a narrated walkthrough with diagrams, spaced review that brings it back before you forget it.
Take the free diagnostic →More in Big Data Projects
- Recognise the stages of a data analysis project and explain each one
- Set out the aims, stages and examples of data preparation and wrangling
- Set out the aims, techniques and examples of exploring data
- Explain techniques for extracting, choosing and engineering features from text data
- Set out the aims, stages and techniques of training a model
- Explain how text-based data is prepared, wrangled and explored for use in financial forecasting