Closed jonthegeek closed 2 years ago
It is probably better to just store the levels in the fit object.
If you are following the model template then right here you have access to the outcomes, so just pluck off the levels and store then in the model result
get_outcome_levels()
could be used on processed$outcomes
if you want, but it takes into account the fact that you might have multiple outcome columns, which is why it returns a list of factor levels.
It is probably simpler for you to just call levels(outcome)
there and store that.
I don't think modifying get_outcome_levels()
is the right solution
Oooh, storing them in the model object is a good option!
I definitely wasn't confident this was the right solution, but it wasn't clear what was. Perhaps a classification vignette would help?
FWIW, tabnet extracts them from the blueprint, which is what led me to that solution.
I'll go ahead and close this issue, since this isn't the right solution. Thanks for the feedback!
This issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with a reprex: https://reprex.tidyverse.org) and link to this issue.
Feature
For "class" predict functions, we need to extract the levels from the blueprint. It took a little digging to figure out where those were. I thought
get_levels
orget_outcome_levels
was pushing in that direction, but ended up just usinglevels(object$blueprint$ptypes$outcomes[[1]])
. It feels like there should be a more obvious solution. Ideally the output should be a character vector if possible, since that's what we need for spruce_prob or to change numeric predictions to the proper labeled factor levels.I may be missing an existing solution, but I can't find it if I am.