| apply_recipe | R Documentation |
Forward translation: takes an original-namespace data frame and
returns it renamed and re-labelled to match the synthetic namespace
produced by mask(). Use this to run a pipeline (trained on the
synthetic) against the original data without modifying pipeline code.
apply_recipe(original, rec, check_integrity = TRUE)
original |
A data frame in the original namespace. |
rec |
A |
check_integrity |
Logical. When |
Operations applied (in order):
Re-apply cleaning and conform decisions: the legalised names and
trimmed labels from clean_table(), then the label merges and type
changes from conform_table() when the clone was built on a
conformance object.
Verify integrity by comparing the NA mask of original to the
SHA-256 fingerprint stored on the recipe (controlled by
check_integrity).
Drop every column whose resolved action was "drop" on the
roles table mask() masked with, in either mode. A linked join key
of a set is aliased in the clone and is kept.
Subset and reorder to the columns the recipe knows about.
Re-label factors / characters for any column with a level map
held by the recipe (i.e., treatment and categorical covariates in
collaborate mode; or treatment in local mode with opt-in
permutation). Unknown non-NA values fail closed.
Rename columns per recipe@column_name_map when mask() was
called with alias_names (otherwise NULL, and names are
unchanged).
Numeric columns are passed through unchanged: the synthetic-namespace for numeric columns is the same as the original. NA cells in the input remain NA in the output (no synthesis is performed here).
A data.table in the synthetic namespace, ready for the pipeline.
unmask(), mask().
r <- propose_roles(iris)
r$role[r$col == "Sepal.Length"] <- "outcome"
r$role[r$col == "Species"] <- "covariate"
m <- mask(iris, r, mode = "collaborate", seed = 1)
rec <- recipe(m)
iris_in_synth_space <- apply_recipe(iris, rec)
head(iris_in_synth_space)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.