predict: Predictions for the Explainer

Description Usage Arguments Value Examples

Description

This is a generic predict() function works for explainer objects.

Usage

1
2
3
4
## S3 method for class 'explainer'
predict(object, newdata, ...)

model_prediction(explainer, new_data, ...)

Arguments

object

a model to be explained, object of the class explainer

newdata

data.frame or matrix - observations for prediction

...

other parameters that will be passed to the predict function

explainer

a model to be explained, object of the class explainer

new_data

data.frame or matrix - observations for prediction

Value

An numeric matrix of predictions

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
HR_glm_model <- glm(status == "fired"~., data = HR, family = "binomial")
explainer_glm <- explain(HR_glm_model, data = HR)
predict(explainer_glm, HR[1:3,])

 ## Not run: 
library("ranger")
HR_ranger_model <- ranger(status~., data = HR, num.trees = 50, probability = TRUE)
explainer_ranger  <- explain(HR_ranger_model, data = HR)
predict(explainer_ranger, HR[1:3,])

model_prediction(explainer_ranger, HR[1:3,])
 
## End(Not run)

DALEX documentation built on July 8, 2020, 7:17 p.m.

Related to predict in DALEX...