Learn R Programming

pipeliner (version 0.1.1)

predict_model: Generate machine learning model prediction

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

predict_model(.m)

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

Run this code
## 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)

Run the code above in your browser using DataLab