makePredictor: User-friendly function to create a Predictor.

View source: R/Predictor.R

makePredictorR Documentation

User-friendly function to create a Predictor.

Description

A wrapper function that creates the correct subclass of Predictor by automatically from model. Can be passed to the constructor of FME.

Usage

makePredictor(model, data)

Arguments

model

the (trained) model, with the ability to predict on new data.

data

the data used for computing FMEs, must be data.frame or data.table.

Examples

# Train a model:

library(mlr3verse)
data(bikes, package = "fmeffects")
task = as_task_regr(x = bikes, id = "bikes", target = "count")
forest = lrn("regr.ranger")$train(task)

# Create the predictor:
predictor = makePredictor(forest, bikes)

# This instantiated an object of the correct subclass of `Predictor`:
class(predictor)

fmeffects documentation built on June 22, 2024, 9:32 a.m.