
The True Positive Rate (TPR), also known as sensitivity, recall, or hit rate, is a fundamental concept in the field of machine learning, particularly in the context of classification problems. It is a statistical measure that provides insights into the performance of a classification model. The TPR is the proportion of actual positive cases that are correctly identified by the model.
What is True Positive Rate?
The True Positive Rate is derived from the concepts of True Positives and False Negatives. True Positives (TP) are the cases where the machine learning model correctly predicts the positive class. For instance, if a model is designed to predict whether an email is spam or not, a TP would be a spam email correctly identified as spam by the model.
On the other hand, False Negatives (FN) are the cases where the model incorrectly predicts the negative class. In the spam email example, a FN would be a spam email that the model incorrectly identifies as not spam. The True Positive Rate is calculated as TP / (TP + FN). This formula shows that the TPR is the proportion of actual positives (TP + FN) that are correctly identified (TP).
Improve your data
quality for better AI
Easily curate and annotate your vision, audio,
and document data with a single platform

Importance of True Positive Rate
The True Positive Rate is a critical measure in machine learning as it provides insights into the model’s ability to correctly identify positive cases. A high TPR indicates that the model is good at detecting positive cases, while a low TPR suggests that the model often misses positive cases.
However, the TPR should not be viewed in isolation. It should be considered alongside other performance measures such as the False Positive Rate (FPR) and Precision. This is because a model that simply classifies all cases as positive will have a high TPR but may also have a high FPR, indicating a large number of false alarms.
True Positive Rate in Different Domains
The importance of the True Positive Rate can vary depending on the domain. In some domains, such as medical diagnosis, a high TPR is crucial as the cost of missing a positive case (a patient with the disease) can be very high. In such cases, a model with a high TPR is preferred even if it has a high FPR, as false alarms (healthy patients incorrectly identified as having the disease) can be managed with further tests.
In other domains, such as spam email detection, a balance between the TPR and the FPR may be more desirable. A model with a high TPR but also a high FPR may result in many legitimate emails being incorrectly classified as spam, which can be annoying for the user. Therefore, the ideal model would have a high TPR and a low FPR.
Calculating the True Positive Rate
The True Positive Rate is calculated using the formula TP / (TP + FN). This formula shows that the TPR is the proportion of actual positives (TP + FN) that are correctly identified (TP). The TPR can be calculated directly from the confusion matrix, which is a table that summarizes the performance of a classification model.
The confusion matrix consists of four elements: True Positives (TP), False Positives (FP), True Negatives (TN), and False Negatives (FN). The TPR can be calculated by dividing the number of TP by the sum of TP and FN. This gives the proportion of actual positive cases that are correctly identified by the model.
Source: https://www.researchgate.net/figure/A-Confusion-matrix-and-its-relation-to-predictive-accuracy-terms-TPRTrue-Positive-Rate_fig7_277034344
Example of Calculating True Positive Rate
Let’s consider an example where a model is used to predict whether a patient has a certain disease. The model is tested on 100 patients, of which 50 actually have the disease. The model correctly identifies 40 of these patients as having the disease (TP), but misses 10 (FN). Therefore, the TPR is calculated as 40 / (40 + 10) = 0.8 or 80%.
This means that the model correctly identifies 80% of the patients who actually have the disease. However, this does not mean that the model is 80% accurate, as the model’s performance on the negative cases is not considered in the TPR. The model’s overall accuracy would be calculated as (TP + TN) / (TP + FP + TN + FN).
Limitations of True Positive Rate
While the True Positive Rate is a useful measure of a model’s performance on positive cases, it has its limitations. One limitation is that the TPR does not consider the model’s performance on negative cases. A model that simply classifies all cases as positive will have a high TPR, but may also have a high False Positive Rate (FPR), indicating a large number of false alarms.
Another limitation is that the TPR can be misleading if the data is imbalanced. If the number of positive cases is much smaller than the number of negative cases (called data imbalance issue), a model that simply classifies all cases as negative will have a low TPR but may still have a high overall accuracy. Therefore, the TPR should be considered alongside other performance measures such as the FPR, Precision, and Recall.
True Positive Rate vs. Other Performance Measures
The True Positive Rate is just one of many performance measures used in machine learning. Other common measures include the False Positive Rate (FPR), Precision, Recall, F1 Score, and Area Under the Receiver Operating Characteristic Curve (AUC-ROC). Each of these measures provides different insights into the model’s performance and is suitable for different scenarios.
The FPR, for instance, is the proportion of actual negative cases that are incorrectly identified by the model. It is calculated as FP / (FP + TN). The FPR is a measure of the model’s false alarms and is particularly important in scenarios where the cost of a false positive is high.
True Positive Rate vs. Precision
The True Positive Rate and Precision are both measures of a model’s performance on positive cases, but they provide different insights. The TPR is the proportion of actual positive cases that are correctly identified by the model, while Precision is the proportion of predicted positive cases that are actually positive. It is calculated as TP / (TP + FP).
A model with a high TPR but low Precision has many true positives but also many false positives. This could be a model that is overly optimistic, classifying many cases as positive. On the other hand, a model with a low TPR but high Precision has few true positives but also few false positives. This could be a model that is overly conservative, classifying few cases as positive.
True Positive Rate vs. F1 Score
The F1 Score is a measure that combines the TPR and Precision. It is the harmonic mean of the TPR and Precision, calculated as 2 * (TPR * Precision) / (TPR + Precision). The F1 Score provides a single measure of a model’s performance on positive cases, taking into account both the model’s ability to correctly identify positive cases (TPR) and its ability to avoid false positives (Precision).
A model with a high F1 Score has both a high TPR and a high Precision. This is a model that is good at detecting positive cases and also good at avoiding false positives. The F1 Score is particularly useful in scenarios where both false positives and false negatives are costly.
Improving the True Positive Rate
Improving the True Positive Rate is often a goal in machine learning, especially in scenarios where the cost of missing a positive case is high. There are several strategies that can be used to improve the TPR, including using a more complex model, adjusting the classification threshold, and using techniques such as oversampling or cost-sensitive learning.
Using a Complex Model
Using a more complex model can potentially improve the TPR by capturing more complex patterns in the data. However, this can also lead to overfitting, where the model performs well on the training data but poorly on new data. Therefore, it is important to validate the model’s performance on a separate test set.
Adjusting the Classification Threshold
The classification threshold is the point at which a case is classified as positive or negative. By default, this threshold is often set at 0.5, meaning that a case is classified as positive if the model’s predicted probability of the positive class is greater than 0.5. However, this threshold can be adjusted to improve the TPR.
Lowering the classification threshold will increase the TPR, as more cases will be classified as positive. However, this will also increase the FPR, as more negative cases will be incorrectly classified as positive. Therefore, adjusting the classification threshold is a trade-off between the TPR and FPR.
Using Oversampling or Cost-Sensitive Learning
Oversampling and cost-sensitive learning are techniques that can be used to improve the TPR in scenarios where the data is imbalanced. Oversampling involves replicating the positive cases in the training data to increase their prevalence, while cost-sensitive learning involves assigning a higher cost to misclassifying positive cases.
These techniques can improve the TPR by making the model more sensitive to the positive cases. However, they can also increase the FPR, as the model may become more likely to classify a case as positive. Therefore, these techniques should be used with caution and the model’s performance should be validated on a separate test set.
Improve your data
quality for better AI
Easily curate and annotate your vision, audio,
and document data with a single platform
