Skip to main content
πŸ”’ Preview mode. The first 15 Foundations lessons are free; this one is Pro. Start a 7-day trial to unlock the editor, AI hints and the the rest of the curriculum. Card required, cancel any time in Dashboard.Start 7-day trial β†’
⚑
← Coursesβ€ΊData Science AppliedModule 3 Β· Modeling & Evaluation Β· Recapβ€ΊπŸŽ― Review: Data Science module 3 recapscenario63 / 104
+80 XP
Task
Build `confusion_matrix_accuracy(tp, tn, fp, fn)` β€” the foundational classification metric: - Formula: `(tp + tn) / (tp + tn + fp + fn)`. - Return float in `[0.0, 1.0]` rounded to 4 decimals. - All four zeros β†’ return `0.0` (avoid division by zero β€” empty test set). - Validate non-negative; treat any negative input β†’ return `0.0` (defensive). Accuracy is the right metric only when classes are roughly balanced β€” but every interviewer wants to see you implement it cleanly first.
✏️ Write your code here
🐍
Loading Python...
One-time download (~1 MB). Then it runs instantly.
πŸ“Š Result
Press Run to see result...

πŸ’¬ Discussion

Be the first to ask a question or share a tip.
Sign in to join the discussion. Reading is free.
Loading discussion…