View source: R/kerasnip_add_tailor.R
| kerasnip_add_tailor | R Documentation |
tailor Post-Processor to One Output or Step of a Multi-Output
or Multistep Workflowworkflows::add_tailor() cannot be used on a kerasnip multi-output or
multistep workflow: tailor::fit() selects outcome/estimate via
[[, which requires exactly one, flat, numeric column, and both a
multi-output recipe (output_1 + output_2 ~ .) and a multistep model's
nested .pred list-column violate that (see
vignette("multi_output_postprocessing")). kerasnip_add_tailor() is a
kerasnip-owned analogue that attaches a tailor post-processor to a
single named output or forecast step, using kerasnip_output_view() or
kerasnip_step_view() internally.
kerasnip_add_tailor(x, tailor, output = NULL, step = NULL, var = NULL)
x |
An unfitted |
tailor |
A |
output |
A string, the name of the outcome column to post-process (multi-output models). |
step |
An integer, the forecast step to post-process (multistep models). |
var |
A string, the forecasted variable to post-process; only
needed with |
At fit() time, the underlying model is trained as usual; the relevant
view is then used to fit the tailor against that output's/step's
predictions (on data_calibration if supplied, otherwise on data,
mirroring workflows::add_tailor()'s data-usage convention). At
predict() time, the full prediction is generated, the target
output's/step's value(s) are replaced with the tailor-adjusted values,
and everything else (other outputs; other steps in the same nested
tibble) is left untouched.
Exactly one of output or step must be supplied: output for a
multi-output model, step (and var, if more than one variable is
forecast) for a multistep model.
A kerasnip_tailored_workflow, to be trained with fit().
## Not run:
tlr <- tailor::tailor() |> tailor::adjust_numeric_calibration()
# multi-output
tailored_wf <- kerasnip_add_tailor(wf, tlr, output = "output_1")
# multistep
tailored_wf <- kerasnip_add_tailor(wf, tlr, step = 2)
fit_obj <- fit(tailored_wf, data = train_data, data_calibration = cal_data)
predict(fit_obj, new_data = test_data)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.