predict_model: Generate machine learning model prediction

Description Usage Arguments Value Examples

View source: R/utils.R

Description

A helper function that takes as its arguement an estimated machine learning model and returns a prediction function for use within a machine learning pipeline.

Usage

1

Arguments

.m

An estimated machine lerning model.

Value

A unary function of a data.frame that returns the input data.frame with the predicted response variable column appended. This function is assigned the classes "predict_model" and "ml_pipeline_section".

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
## Not run: 
data <- head(faithful)
m <- estimate_model(function(df) {
  lm(eruptions ~ 1 + waiting, df)
})

predict_model(m(data))(data, "pred_eruptions")
#   eruptions waiting pred_eruptions
# 1     3.600      79       3.803874
# 2     1.800      54       2.114934
# 3     3.333      74       3.466086
# 4     2.283      62       2.655395
# 5     4.533      85       4.209219
# 6     2.883      55       2.182492

## End(Not run)

AlexIoannides/pipeliner documentation built on May 5, 2019, 4:52 a.m.