Repository navigation
Conversation
|
This PR fixes #364 by adding an opt-in held-out R2 for linear-model cross-validation. It computes the score within each test fold and keeps the existing defaults. The regression tests compare the scores and intervals with a direct calculation. |
9c62a1e to
e12d3db
Compare
|
Rebased the fix for #364 onto current main, which includes the recent test repairs. All 13 focused assertions, installed-package coverage, and lint passed locally. |
There was a problem hiding this comment.
🟡 Changes recommended
A moderate active issue remains because the guard can allow overflow to produce a non-finite score that is not filtered before aggregation.
1 open issue
1 file not reviewed
man/performance_accuracy.Rd: Generated file
What changed in this PR
Adds opt-in held-out R² scoring to performance_accuracy() for linear models using cross-validation while preserving existing correlation and AUC defaults.
Changes:
- Adds fold-level R² calculation with finite-score summarization and validation.
- Adds tests for R² behavior, edge cases, and backward compatibility.
- Updates documentation, NEWS, and the development version.
| File | Description |
|---|---|
| tests/testthat/test-performance_accuracy.R | Adds tests for R² calculations, validation, edge cases, and default compatibility. |
| R/performance_accuracy.R | Implements metric selection and held-out R² scoring for cross-validation. |
| NEWS.md | Documents the addition of held-out R² scoring. |
| man/performance_accuracy.Rd | Documents the new metric argument and R² behavior. |
| DESCRIPTION | Increments the package development version. |
Review effort: Lite
| if (total == 0 || !is.finite(total) || !is.finite(error)) { | ||
| return(NA_real_) | ||
| } | ||
| 1 - error / total |
|
Minimal change requested here - not sure if this really can become an issue? You may ignore this request. |

Summary
Fixes #364.
metric = "r2"for linear models withmethod = "cv". Calculate the score in each test fold and summarize the finite scores with the existing return fields.Evidence
performance_cv(stack = FALSE).Status: OKwith examples enabled. The command used--no-manual --ignore-vignettes --no-tests.Merge Danger
Door Two-way
The new score is opt-in through a trailing argument.