Back to Practice
#0120

Threshold Probabilities

EasyML15 min10 XP

Problem

Given probabilities and threshold, return 1 when probability >= threshold else 0.

Why This Matters

Classification thresholds change precision, recall, and business behavior. The default 0.5 is not always best.

Function Signature

def threshold_probs(probabilities, threshold):

Examples

Example 1
Input[0.2, 0.5, 0.8], threshold=0.5
Output[0, 1, 1]

The threshold is inclusive.

Constraints

  • Return the requested value exactly.
  • Handle the stated edge cases.
  • Keep the solution readable.
CodePython
Visible browser tests run here when available.
Testcases1 visible / 3 hidden categories
Core example
Input[0.2, 0.5, 0.8], threshold=0.5
Expected[0, 1, 1]

The threshold is inclusive.

Hidden Test Categories
empty listthreshold 0threshold 1