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.
Arguments
- original
A data frame in the original namespace.
- rec
A
masque_recipeobject (e.g. fromrecipe(m)).- check_integrity
Logical. When
TRUE(default), verifies that the NA mask oforiginalmatches the recipe's recordedintegrity_fp. Mismatches error with guidance. PassFALSEto bypass when the missingness has legitimately changed since the recipe was built.
Details
Operations applied (in order):
Verify integrity by comparing the NA mask of
originalto the SHA-256 fingerprint stored on the recipe (controlled bycheck_integrity).Drop columns that
mask()dropped (incollaboratemode this is everyignorecolumn; inlocalmode no columns are dropped).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
collaboratemode; or treatment inlocalmode with opt-in permutation). Unknown non-NA values fail closed.Rename columns per
recipe@column_name_map(currentlyNULL; reserved for a future opt-in column-aliasing flag — seevignette("roadmap")).
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).
Examples
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)
#> # A tibble: 6 × 5
#> Sepal.Length Sepal.Width Petal.Length Petal.Width Species
#> <dbl> <dbl> <dbl> <dbl> <fct>
#> 1 5.1 3.5 1.4 0.2 Species_L001
#> 2 4.9 3 1.4 0.2 Species_L001
#> 3 4.7 3.2 1.3 0.2 Species_L001
#> 4 4.6 3.1 1.5 0.2 Species_L001
#> 5 5 3.6 1.4 0.2 Species_L001
#> 6 5.4 3.9 1.7 0.4 Species_L001