BOT: Fix #942: Add plot_discrimination() for binary forecasts#1079
Open
nikosbosse wants to merge 7 commits intomainfrom
Open
BOT: Fix #942: Add plot_discrimination() for binary forecasts#1079nikosbosse wants to merge 7 commits intomainfrom
nikosbosse wants to merge 7 commits intomainfrom
Conversation
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1079 +/- ##
==========================================
+ Coverage 97.98% 98.00% +0.02%
==========================================
Files 37 38 +1
Lines 1984 2006 +22
==========================================
+ Hits 1944 1966 +22
Misses 40 40 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
nikosbosse
commented
Feb 13, 2026
Collaborator
Author
nikosbosse
left a comment
There was a problem hiding this comment.
CLAUDE: Approved. Clean implementation of plot_discrimination() that follows all existing package conventions (ensure_data.table, check_columns_present, theme_scoringutils). All 7 tests match specifications and pass. Only minor nitpick: unused @importFrom checkmate assert_data_frame import — harmless but unnecessary.
- Use expect_gte() instead of expect_true(x >= y) to satisfy expect_comparison_linter - Skip vdiffr snapshot tests on R < 4.2 where density estimation produces different SVG output Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Collaborator
Author
Default to histogram with density on y-axis; density curves available via type = "density". Removes old vdiffr snapshots that only worked with one plot type and updates tests accordingly. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Collaborator
Author
Allows users to pass arguments like bins, binwidth, bw, or adjust directly through to the underlying geom. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Proportions are computed within each observed level so both groups sum to 1, making the distribution shapes directly comparable regardless of sample size differences. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add nolint annotations for false positive object_usage_linter warnings caused by ... forwarding, and add group to globalVariables. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Summary
plot_discrimination()function that visualises the discrimination ability of binary forecasts by plotting overlapping density curves of predicted probabilities, stratified by observed outcome levelensure_data.table(),check_columns_present(),theme_scoringutils())Closes #942
Root cause
No binary-specific plot functions existed in the codebase. The
forecast_binaryclass andexample_binarydataset provided the data structures but there was no way to visualise discrimination ability.What changed
R/plot-discrimination.Rwithplot_discrimination()— accepts a data.frame/data.table withobserved(factor) andpredicted(numeric) columns, renders overlapping density plots via ggplot2tests/testthat/test-plot_discrimination.Rwith 7 test cases and 2 visual regression snapshotsTest plan
🤖 Generated with Claude Code