Skip to content

BOT: Fix #942: Add plot_discrimination() for binary forecasts#1079

Draft
nikosbosse wants to merge 1 commit intomainfrom
fix/942-discrimination-plot-binary
Draft

BOT: Fix #942: Add plot_discrimination() for binary forecasts#1079
nikosbosse wants to merge 1 commit intomainfrom
fix/942-discrimination-plot-binary

Conversation

@nikosbosse
Copy link
Collaborator

Summary

  • Adds a new plot_discrimination() function that visualises the discrimination ability of binary forecasts by plotting overlapping density curves of predicted probabilities, stratified by observed outcome level
  • Includes 7 tests covering basic usage, faceting, plain data.frame input, missing columns, single-model data, separation verification, and edge cases
  • Follows existing plot function conventions (ensure_data.table(), check_columns_present(), theme_scoringutils())

Closes #942

Root cause

No binary-specific plot functions existed in the codebase. The forecast_binary class and example_binary dataset provided the data structures but there was no way to visualise discrimination ability.

What changed

  • New file R/plot-discrimination.R with plot_discrimination() — accepts a data.frame/data.table with observed (factor) and predicted (numeric) columns, renders overlapping density plots via ggplot2
  • New test file tests/testthat/test-plot_discrimination.R with 7 test cases and 2 visual regression snapshots
  • NAMESPACE updated to export the new function

Test plan

  • All 7 new tests pass
  • Full test suite passes (689 tests, 0 failures)
  • R CMD check: 0 errors, 0 warnings, 2 notes (pre-existing)

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@codecov
Copy link

codecov bot commented Feb 13, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.84%. Comparing base (ac0c01a) to head (cc0dbc2).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1079      +/-   ##
==========================================
+ Coverage   97.83%   97.84%   +0.01%     
==========================================
  Files          35       36       +1     
  Lines        1845     1857      +12     
==========================================
+ Hits         1805     1817      +12     
  Misses         40       40              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Collaborator Author

@nikosbosse nikosbosse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@nikosbosse nikosbosse marked this pull request as draft February 13, 2026 08:27
@nikosbosse nikosbosse changed the title Fix #942: Add plot_discrimination() for binary forecasts BOT: Fix #942: Add plot_discrimination() for binary forecasts Feb 13, 2026
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.

Discrimination plots for binary forecasts

1 participant