Lesson 5 of 15
Decision Boundary & Metrics
Decision Boundary & Classification Metrics
A logistic regression model outputs a probability . To make a hard prediction (0 or 1) we apply a threshold (usually 0.5):
Evaluation Metrics
Once we have hard predictions we can measure quality with:
| Metric | Formula | Meaning |
|---|---|---|
| Accuracy | Fraction correct | |
| Precision | Of predicted positives, how many are real? | |
| Recall | Of real positives, how many did we catch? |
where TP = true positives, TN = true negatives, FP = false positives, FN = false negatives.
Zero-division: if the denominator is zero, return 0.0.
Your Task
Implement:
classify(x, w, b, threshold=0.5)→ 0 or 1accuracy(y_pred, y_true)→ fraction of correct predictionsprecision(y_pred, y_true)→ TP / (TP + FP), 0.0 on zero-divisionrecall(y_pred, y_true)→ TP / (TP + FN), 0.0 on zero-division
Python runtime loading...
Loading...
Click "Run" to execute your code.