Calculate Precision, Recall, and F1

Quick Overview

This Intuit Data Scientist technical-screen question tests your ability to compute confusion-matrix counts (TP, FP, TN, FN) and derive precision, recall, and F1 for the positive class from binary classification outputs. It also probes how to threshold confidence scores into predictions and how to handle zero-denominator edge cases.

Calculate Precision, Recall, and F1

Company: Intuit

Role: Data Scientist

Category: Statistics & Math

Difficulty: medium

Interview Round: Technical Screen

##### Question You are given a list of binary classification outputs, where class `1` is the positive class. Each record contains: - `actual` (INT, `0` or `1`) - `predicted` (INT, `0` or `1`) - `confidence` (FLOAT, the model's confidence score for the positive class) Example record: `{"actual": 1, "predicted": 0, "confidence": 0.93}`. Using the provided `actual` and `predicted` labels, write Python or pseudocode that: 1. Computes the confusion-matrix counts for the positive class: `TP`, `FP`, `TN`, `FN`. 2. Calculates `precision`, `recall`, and the `F1 score` over the full dataset. 3. Explains how you would derive `predicted` from `confidence` if the interviewer asks you to apply a decision threshold instead of using the provided predicted labels, and how the metrics change as the threshold changes. 4. Handles edge cases where a denominator becomes zero (for example, no predicted positives or no actual positives).

Overview: This Intuit Data Scientist technical-screen question tests your ability to compute confusion-matrix counts (TP, FP, TN, FN) and derive precision, recall, and F1 for the positive class from binary classification outputs. It also probes how to threshold confidence scores into predictions and how to handle zero-denominator edge cases.

Community answers

Answer by sindhujakasula03

Lets start with confusion Matrix TP - count of Class 1 flagged and actual class 1 FP - count of Class 1 flagged and but actual class is 0 TN - count of Class 0 flagged and actual class 0 FN - count of Class 0 flagged and but actual class is 1 Predicted class 1= TP+FP Actual class 1= TP+FN precision is metric to measure true positives vs whole of Predicted Positives. (count all class 1 predicted and actual class 1)/ (count all class 1 predictions). TP/P Recall is metric to how many true class predicted vs whole actaully true count all class 1 predicted and actual / count of all 1 actuals TP/TP+FN F1 Score is a balance metric - 2PR/(P+R) Apply sigmoid function on confidence to get output as a label. Area under the precision-recall curve drops as the threshold is lowered
|Home/Statistics & Math/Intuit
Intuit logo
Intuit
Feb 10, 2026
mediumData ScientistTechnical ScreenStatistics & Math
17
0
Question

You are given a list of binary classification outputs, where class 1 is the positive class. Each record contains:

  • actual (INT, 0 or 1 )
  • predicted (INT, 0 or 1 )
  • confidence (FLOAT, the model's confidence score for the positive class)

Example record: {"actual": 1, "predicted": 0, "confidence": 0.93}.

Using the provided actual and predicted labels, write Python or pseudocode that:

  1. Computes the confusion-matrix counts for the positive class: TP , FP , TN , FN .
  2. Calculates precision , recall , and the F1 score over the full dataset.
  3. Explains how you would derive predicted from confidence if the interviewer asks you to apply a decision threshold instead of using the provided predicted labels, and how the metrics change as the threshold changes.
  4. Handles edge cases where a denominator becomes zero (for example, no predicted positives or no actual positives).
Loading comments...