Repository navigation
Add orbital.model_stack() for stacks::stacks() ensembles - #191
Merged
Merged
Conversation
Referencing `norm` unquoted still evaluated correctly on its own, but made every occurrence of that column name text-identical across expressions, which blocks any caller that needs to rename these equations' columns by substituting backtick-quoted references (as orbital.model_stack() needs to do for multiclass ensemble members).
A fitted model_stack's blending model (x$coefs) is already an ordinary parsnip model_fit wrapping a glmnet fit, so orbital(x$coefs) works unmodified; its preproc term labels are exactly the member prediction column names it expects as predictors. This method builds each member workflow's own equations, renames their outputs (and any internal cross-references between them) to match those expected column names, and splices the result with the blend model's own equations.
rename_stack_member_eqs() relocated cross-references between a member's own equations by gsub-ing for backtick-quoted names. That matches orbital's hand-written glue templates, which always backtick their references, but not tidypredict-generated expressions such as separate_trees_eqs()'s tree-averaging formula, which only backticks a name when it isn't already a syntactically valid identifier (e.g. `.pred_tree_1` comes out bare). The gsub silently missed those bare references, so orbital(stack, separate_trees = TRUE) produced equations that referenced columns which no longer existed under their renamed member-suffixed names. Switch to substituting at the parsed-expression level instead, which works regardless of whether the reference happens to be backtick-quoted, and as a side effect no longer needs the longest-name- first ordering that guarded against substring collisions.
Cover paths the original test suite left untested: a type/mode mismatch, prefix forwarding to just the blend model's output, separate_trees propagating into a tree-based member, a member's build failure being wrapped with its name, the member name-collision guard, check_fitted_stack()'s other failure branches, rename_stack_member_eqs() directly (including the norm/norm2 substring-safety case its own comment calls out), type = "class"/"prob" requested alone, and a stack with three distinct member model types.
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.
orbital()now supports fittedstacks::stacks()ensembles. A stack's blending model is already an ordinary parsnipglmnetfit, so this reuses each member workflow's ownorbital()equations, renames their outputs to match what the blend model expects as predictors, and splices the two together. Closes #54.