True Positive (TP)

In the context of machine learning and statistical analysis, True Positive (TP) refers to an outcome where the model correctly identifies a positive instance. It is a crucial metric in performance evaluation, particularly in classification problems, as it measures the number of actual positives correctly predicted by the model.


Definition of True Positive

A True Positive occurs when the model predicts the positive class (e.g., “Yes,” “Positive,” or “1”) for an instance that is genuinely positive. For instance, in a medical test scenario, if the model correctly predicts a patient as having a disease when the patient indeed has it, it is considered a True Positive.


Position of True Positive in a Confusion Matrix

The confusion matrix is a 2×2 table that summarizes the performance of a classification model. Here’s how the True Positive fits into the matrix:

Predicted PositivePredicted Negative
Actual PositiveTrue Positive (TP)False Negative (FN)
Actual NegativeFalse Positive (FP)True Negative (TN)
True Positive in a Confusion Matrix

Detailed Examples with Steps to Calculate True Positive

Let’s explore several examples to understand how True Positives are calculated in real-world scenarios. In each example, we will use the confusion matrix format and calculate the TP value step by step.


Example 1: Spam Email Detection

Scenario: A model predicts whether an email is spam.

  • Total emails: 100
  • Actual spam emails: 40
  • Predicted spam emails: 45
  • Correctly identified spam emails: 35

Steps:

  1. Identify the number of correctly predicted positive cases (spam emails).
  2. Here, TP = 35.

Example 2: Medical Diagnosis

Scenario: A model predicts whether a patient has a specific disease.

  • Total patients: 200
  • Actual cases with the disease: 50
  • Predicted cases with the disease: 55
  • Correctly identified cases with the disease: 45

Steps:

  1. Count the correctly predicted cases (True Positives).
  2. Here, TP = 45.

Example 3: Fraud Detection

Scenario: A model predicts whether a transaction is fraudulent.

  • Total transactions: 1,000
  • Actual fraudulent transactions: 100
  • Predicted fraudulent transactions: 120
  • Correctly identified fraudulent transactions: 90

Steps:

  1. Identify the correctly predicted fraudulent transactions.
  2. Here, TP = 90.

Example 4: Cancer Detection

Scenario: A model predicts whether a patient has cancer based on medical tests.

  • Total patients: 500
  • Actual cancer cases: 80
  • Predicted cancer cases: 85
  • Correctly identified cancer cases: 75

Steps:

  1. Count the correctly predicted cancer cases.
  2. Here, TP = 75.

Example 5: Sentiment Analysis

Scenario: A model predicts whether a product review is positive.

  • Total reviews: 1,000
  • Actual positive reviews: 600
  • Predicted positive reviews: 650
  • Correctly identified positive reviews: 550

Steps:

  1. Identify the correctly predicted positive reviews.
  2. Here, TP = 550.

Example 6: Face Recognition

Scenario: A model predicts whether a face matches a specific person.

  • Total images: 300
  • Actual matches: 50
  • Predicted matches: 60
  • Correctly identified matches: 45

Steps:

  1. Count the correctly predicted matches.
  2. Here, TP = 45.

Example 7: Loan Approval

Scenario: A model predicts whether a loan applicant will repay the loan.

  • Total applicants: 800
  • Actual repayers: 300
  • Predicted repayers: 320
  • Correctly identified repayers: 280

Steps:

  1. Identify the correctly predicted loan repayers.
  2. Here, TP = 280.

Example 8: Object Detection

Scenario: A model predicts whether an object in an image is a car.

  • Total objects: 1,000
  • Actual cars: 200
  • Predicted cars: 210
  • Correctly identified cars: 190

Steps:

  1. Count the correctly predicted cars.
  2. Here, TP = 190.

Example 9: Product Defect Detection

Scenario: A model predicts whether a product is defective.

  • Total products: 500
  • Actual defective products: 50
  • Predicted defective products: 55
  • Correctly identified defective products: 48

Steps:

  1. Count the correctly predicted defective products.
  2. Here, TP = 48.

Example 10: Fraudulent Insurance Claims

Scenario: A model predicts whether an insurance claim is fraudulent.

  • Total claims: 1,000
  • Actual fraudulent claims: 100
  • Predicted fraudulent claims: 110
  • Correctly identified fraudulent claims: 95

Steps:

  1. Identify the correctly predicted fraudulent claims.
  2. Here, TP = 95.

Conclusion

True Positives are a fundamental component of performance evaluation in machine learning models. By understanding and calculating TP values, practitioners can assess the accuracy and reliability of their models in various real-world scenarios. These examples demonstrate how True Positives provide valuable insights into model performance.