predict.LocalModel: Predict LocalModel

View source: R/LocalModel.R

predict.LocalModelR Documentation

Predict LocalModel

Description

Predict the response for newdata with the LocalModel model.

Usage

## S3 method for class 'LocalModel'
predict(object, newdata = NULL, ...)

Arguments

object

A LocalModel R6 object

newdata

A data.frame for which to predict

...

Further arguments for the objects predict function

Value

A data.frame with the predicted outcome.

See Also

LocalModel

Examples

library("randomForest")
# First we fit a machine learning model on the Boston housing data
data("Boston", package = "MASS")
X <- Boston[-which(names(Boston) == "medv")]
rf <- randomForest(medv ~ ., data = Boston, ntree = 50)
mod <- Predictor$new(rf, data = X)

# Explain the first instance of the dataset with the LocalModel method:
x.interest <- X[1, ]
lemon <- LocalModel$new(mod, x.interest = x.interest, k = 2)
predict(lemon, newdata = x.interest)

iml documentation built on May 29, 2024, 1:59 a.m.