workflows icon indicating copy to clipboard operation
workflows copied to clipboard

axe_data does not remove pre$mold$extras

Open era127 opened this issue 2 years ago • 3 comments
trafficstars

The axe_data.workflow() function does not remove the mold$extras like it does for outcomes and predictors. If a column of data is set to be another role, the model will retain all of that data. Would it be OK to also remove pre$mold$extras or was it intentionally retained for predictions?

The 'outcomes' and 'predictors' are removed here.

axe_data.workflow <- function(x, verbose = FALSE, ...) {
  fit <- extract_fit_parsnip(x)
  fit <- butcher::axe_data(fit, verbose = verbose, ...)
  x <- replace_workflow_fit(x, fit)

  x <- replace_workflow_outcomes(x, NULL)
  x <- replace_workflow_predictors(x, NULL)

  add_butcher_class(x)
}

era127 avatar Jun 29 '23 15:06 era127

Removing extras makes sense to me.

according to ?axe_data.workflow it reads:

After calling butcher::butcher() on a workflow, the only guarantee is that you will still be able to predict() from that workflow

And I don't see $pre$mold$extras being used for prediction right now

EmilHvitfeldt avatar Jun 30 '23 01:06 EmilHvitfeldt

Would the code change be similar to the others and add a new function call to set $extras to NULL:

  x <- replace_workflow_extras(x, NULL)

or would we want to preserve $extras$offset, $extras$id or extras$case_weights. I'm not sure I fully understand the use of those roles.

era127 avatar Jul 01 '23 01:07 era127

@simonpcouch should be able to confirm. But I'm pretty sure we don't need them for prediction

EmilHvitfeldt avatar Jul 01 '23 01:07 EmilHvitfeldt