Explore Library
Code QuizIntermediate

Thresholding Probabilities to Labels

Converting predicted probabilities to class labels using a decision threshold.

Codepython
import numpy as np

probs = np.array([0.2, 0.7, 0.5, 0.9, 0.4])
threshold = 0.5

# Classify as positive (1) if probability exceeds threshold
predictions = (probs > threshold).astype(int)
print(predictions)

The team wants any probability at or above 0.5 to count as positive. What is the bug?