Skip to content

fix(phase-02/03): handle empty cells in Julia build_metrics - #435

Open
pchukwuemeka424 wants to merge 1 commit into
rohitg00:mainfrom
pchukwuemeka424:fix/434-logistic-build-metrics-empty-sum
Open

pchukwuemeka424 wants to merge 1 commit into
rohitg00:mainfrom
pchukwuemeka424:fix/434-logistic-build-metrics-empty-sum

Conversation

@pchukwuemeka424

Copy link
Copy Markdown

Summary

Test plan

  • Unit-style checks: all-negative and all-positive predictions return correct TP/TN/FP/FN without throwing
  • julia main.jl / full main() completes through threshold tuning and the rest of the demo
  • CI audit passes on the PR

Made with Cursor

Strict thresholds can yield all-negative predictions; filtered sum()
then throws ArgumentError on empty generators during threshold tuning.

Co-authored-by: Cursor <[email protected]>
@coderabbitai

coderabbitai Bot commented Aug 25, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: b549a748-1efe-4daf-8bfd-630ed0363819

📥 Commits

Reviewing files that changed from the base of the PR and between 39ea8a1 and 14a4671.

📒 Files selected for processing (1)
  • phases/02-ml-fundamentals/03-logistic-regression/code/main.jl

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.


📝 Walkthrough

Walkthrough

build_metrics now computes TP, TN, FP, and FN with indexed count predicates. Empty matches return zero instead of raising an ArgumentError.

Changes

Classification metrics robustness

Layer / File(s) Summary
Indexed metric count calculation
phases/02-ml-fundamentals/03-logistic-regression/code/main.jl
build_metrics replaces generator-based sum calculations with indexed count predicates for TP, TN, FP, and FN. Empty matches return zero.

Estimated code review effort: 2 (Simple) | ~5 minutes

Merge Risk: ⚪ Minimal · up to 14a46

The change makes threshold tuning return zero counts for empty prediction groups instead of throwing; no actionable merge-blocking risk remains after normal checks and review.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the fix to build_metrics for empty cells in the Phase 2 logistic regression lesson.
Description check ✅ Passed The description directly explains the build_metrics crash, the count(...) fix, and the related validation plan.
Linked Issues check ✅ Passed The changes address issue #434 by preventing empty-generator reduction errors and preserving correct TP, TN, FP, and FN calculations during threshold tuning.
Out of Scope Changes check ✅ Passed The changes are limited to the scoped build_metrics implementation in the file identified by issue #434. No unrelated code changes are described.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 0…
Full details: Docstring Coverage

Explanation

No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 0 files. (1 skipped: 1 unsupported.)

✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug] ArgumentError in build_metrics during threshold tuning (03-logistic-regression)

1 participant