estimate_model {pipeliner}R Documentation

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

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

[Package pipeliner version 0.1.1 Index]