Learn R Programming

pipeliner (version 0.1.1)

predict.ml_pipeline: Predict method for ML pipelines

Description

Predict method for ML pipelines

Usage

"predict"(object, data, verbose = FALSE, pred_var = "pred_model", ...)

Arguments

object
An estimated pipleine object of class ml_pipeline.
data
A data.frame in which to look for input variables with which to predict.
verbose
Boolean - whether or not to return data.frame with all input and interim variables as well as predictions.
pred_var
Name to assign to for column of predictions from the 'raw' (or inner) model in the pipeline.
...
Any additional arguements than need to be passed to the underlying model's predict methods.

Value

A vector of model predictions or scores (default); or, a data.frame containing the predicted values, input variables, as well as any interim tranformed variables.

Examples

Run this code
data <- faithful

lm_pipeline <-
  pipeline(
    data,
    estimate_model(function(df) {
      lm(eruptions ~ 1 + waiting, df)
    })
  )

in_sample_predictions <- predict(lm_pipeline, data)
head(in_sample_predictions)
# [1] 4.100592 2.209893 3.722452 2.814917 4.554360 2.285521

Run the code above in your browser using DataLab