linear predictions#28
Merged
Merged
Conversation
…engine Manual initialization: Un-commented draft `parsnip::set_pred()` registration for `"linear_pred"` prediction type. OpenCode prompt: ``` Draft a chunk of unit tests for the `linear_pred` prediction type for the `ordinalNet` engine of the `ordinal_reg` model. Check that the tests pass; if they don't, then identify, diagnose, and patch any bugs in the tests or in the source code that facilitates that prediction type. For this task, follow the structure and style of the 'ordered' package in this directory and of the 'censored' package located at the local path '../censored/'. Focus only on files with the '.R' extension. Also follow tidyverse and tidymodels conventions, and do not use any Git commands. ``` OpenCode report: ``` Here's a summary of what was done: Changes Made 1. Bug fix: blocked linear_pred for classification mode R/ordinal_reg-ordinalNet.R — predict._ordinalNet() calls predict.model_fit() which uses parsnip's check_pred_type(). That function only allows linear_pred for "censored regression" mode, but ordinal_reg uses "classification" mode. Fixed by intercepting type = "linear_pred" in predict._ordinalNet() and directly calling predict_linear_pred() (which dispatches to predict_linear_pred.model_fit() using the set_pred registration). 2. Updated outdated REVIEW comment R/ordinal_reg-data.R — Replaced the REVIEW comment about why linear_pred was restricted. 3. Added unit tests tests/testthat/test-ordinal_reg-ordinalNet.R — Added two tests: - linear_pred prediction — verifies output structure (tibble, correct rows/cols, column names like .pred_link_Low_Medium) and compares values against raw ordinalNet::predict.ordinalNet(type = "link") - linear_pred prediction with single observation — verifies single-row prediction works correctly ``` Manual revisions: 1. In `check_pred_type()`, check for inheritance of `"ordinal_reg"` class rather than for `"classification"` mode. In `predict._ordinalNet()`, comment on the fix. 2. Clarify comment to remain up for review. 3. Changed object names and coerced to tibbles for consistency with other tests.
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.
This PR provides linear prediction options (
predict(..., type = "linear_pred")) for theclm,lrm,orm,vglm, andordinalNetordinal regression engines and for thevgamgeneralized additive model engine. They consistently return a single column of linear predictors (without threshold contributions).This PR depends on an enabling change in parsnip, which will be the subject of a forthcoming PR (just opened here).