Learn R Programming

pipeliner (version 0.1.1)

estimate_model: Estimate machine learning model

Description

A function that takes as its arguement another function defining how a machine learning model should be estimated based on the variables available in the input data frame. This function is wrapped (or adapted) for use within a machine learning pipeline.

Usage

estimate_model(.f)

Arguments

.f
A unary function of a data.frame that returns a fitted model object, which must have a predict.{model-class} defined and available in the enclosing environment. An error will be thrown if any of these criteria are not met.

Value

A unary function of a data.frame that returns a fitted model object that has a predict.{model-class} defined This function is assigned the classes "estimate_model" and "ml_pipeline_section".

Examples

Run this code
data <- head(faithful)
f <- estimate_model(function(df) {
  lm(eruptions ~ 1 + waiting, df)
})

f(data)
# Call:
#   lm(formula = eruptions ~ 1 + waiting, data = df)
#
# Coefficients:
# (Intercept)      waiting
#    -1.53317      0.06756

Run the code above in your browser using DataLab