add_perturb.Rd
add_perturb()
adds an perturbation step to a transformation pipeline
(NB: intended for numeric data). When ran as a transformation, each
specified variable is transformed by the noise
function.
add_perturb(object, ..., noise = adaptive_noise(0.1))
A 'DeidentList' representing the untrained transformation pipeline. The object contains fields:
deident_methods
a list of each step in the pipeline (consisting of variables
and method
)
and methods:
mutate
apply the pipeline to a new data set
to_yaml
serialize the pipeline to a '.yml' file
pipe.perturb <- add_perturb(ShiftsWorked, `Daily Pay`)
pipe.perturb$mutate(ShiftsWorked)
#> # A tibble: 3,100 × 7
#> `Record ID` Employee Date Shift `Shift Start` `Shift End` `Daily Pay`
#> <int> <chr> <date> <chr> <chr> <chr> <dbl>
#> 1 1 Maria Cook 2015-01-01 Night 17:01 00:01 82.3
#> 2 2 Stephen C… 2015-01-01 Day 08:01 16:01 159.
#> 3 3 Kimberly … 2015-01-01 Day 08:01 16:01 65.9
#> 4 4 Nathan Al… 2015-01-01 Day 08:01 15:01 210.
#> 5 5 Samuel Pa… 2015-01-01 Night 16:01 23:01 228.
#> 6 6 Scott Mor… 2015-01-01 Night 17:01 00:01 141.
#> 7 7 Nathan Sa… 2015-01-01 Rest NA NA -8.57
#> 8 8 Jose Lopez 2015-01-01 Night 17:01 00:01 213.
#> 9 9 Donna Bro… 2015-01-01 Night 16:01 00:01 212.
#> 10 10 George Ki… 2015-01-01 Night 16:01 00:01 228.
#> # ℹ 3,090 more rows
pipe.perturb.white_noise <- add_perturb(ShiftsWorked, `Daily Pay`, noise = white_noise(0.1))
pipe.perturb.white_noise$mutate(ShiftsWorked)
#> # A tibble: 3,100 × 7
#> `Record ID` Employee Date Shift `Shift Start` `Shift End` `Daily Pay`
#> <int> <chr> <date> <chr> <chr> <chr> <dbl>
#> 1 1 Maria Cook 2015-01-01 Night 17:01 00:01 78.1
#> 2 2 Stephen C… 2015-01-01 Day 08:01 16:01 155.
#> 3 3 Kimberly … 2015-01-01 Day 08:01 16:01 77.8
#> 4 4 Nathan Al… 2015-01-01 Day 08:01 15:01 203.
#> 5 5 Samuel Pa… 2015-01-01 Night 16:01 23:01 211.
#> 6 6 Scott Mor… 2015-01-01 Night 17:01 00:01 142.
#> 7 7 Nathan Sa… 2015-01-01 Rest NA NA -0.0815
#> 8 8 Jose Lopez 2015-01-01 Night 17:01 00:01 213.
#> 9 9 Donna Bro… 2015-01-01 Night 16:01 00:01 219.
#> 10 10 George Ki… 2015-01-01 Night 16:01 00:01 242.
#> # ℹ 3,090 more rows
pipe.perturb.noisy_adaptive <- add_perturb(ShiftsWorked, `Daily Pay`, noise = adaptive_noise(1))
pipe.perturb.noisy_adaptive$mutate(ShiftsWorked)
#> # A tibble: 3,100 × 7
#> `Record ID` Employee Date Shift `Shift Start` `Shift End` `Daily Pay`
#> <int> <chr> <date> <chr> <chr> <chr> <dbl>
#> 1 1 Maria Cook 2015-01-01 Night 17:01 00:01 134.
#> 2 2 Stephen C… 2015-01-01 Day 08:01 16:01 250.
#> 3 3 Kimberly … 2015-01-01 Day 08:01 16:01 0.934
#> 4 4 Nathan Al… 2015-01-01 Day 08:01 15:01 342.
#> 5 5 Samuel Pa… 2015-01-01 Night 16:01 23:01 398.
#> 6 6 Scott Mor… 2015-01-01 Night 17:01 00:01 228.
#> 7 7 Nathan Sa… 2015-01-01 Rest NA NA -71.7
#> 8 8 Jose Lopez 2015-01-01 Night 17:01 00:01 314.
#> 9 9 Donna Bro… 2015-01-01 Night 16:01 00:01 414.
#> 10 10 George Ki… 2015-01-01 Night 16:01 00:01 197.
#> # ℹ 3,090 more rows