mungebit: Constructor for mungebit class.

Description Usage Arguments See Also Examples

Description

Mungebits are atomic data transformations of a data.frame that, loosely speaking, aim to modify "one thing" about a variable or collection of variables. This is pretty loosely defined, but examples include dropping variables, mapping values, discretization, etc.

Imagine flipping a switch on a set of train tracks. A mungebit behaves like this: once the trained switch is flipped, it can only run the predict_fn, otherwise it will run the train_fn.

Run the predict function on a mungebit.

Run the train function on a mungebit.

Usage

1
2
3
4
5
6
7
8

Arguments

train_fn

function. This specifies the behavior to perform on the dataset when preparing for model training. A value of NULL specifies that there should be no training step.

predict_fn

function. This specifies the behavior to perform on the dataset when preparing for model prediction. A value of NULL specifies that there should be no prediction step.

enforce_train

logical. Whether or not to flitch the trained flag during runtime.

mungeplane

mungeplane. Essentially an environment containing a data variable.

...

additional arguments to the mungebit's train_fn or predict_fn.

See Also

mungepiece

mungebit__initialize

mungebit__run, mungebit__initialize

mungebit__run, mungebit__initialize

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
## Not run: 
mp <- mungeplane(iris)
mb <- mungebit(column_transformation(function(col, scale = NULL) {
  if ('scale' %in% names(inputs))
    cat("Column scaled by ", inputs$scale, "\n")
  else inputs$scale <<- scale
  col * inputs$scale
}))
mb$run(mp, 'Sepal.Length', 2)
# mp$data now contains a copy of iris w/ the Sepal.Length column doubled
head(mp$data[[1]] / iris[[1]])
# > [1] 2 2 2 2 2 2
mb$run(mp, 'Sepal.Length')
# > Column scaled by 2
head(mp$data[[1]] / iris[[1]])
# > [1] 4 4 4 4 4 4

## End(Not run)

robertzk/mungebits documentation built on May 27, 2019, 10:35 a.m.