inst/doc/classification_example.R

## ----setup, include = FALSE---------------------------------------------------
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  warning = FALSE,
  message = FALSE,
  error = FALSE
)

## ----model--------------------------------------------------------------------
library(DALEX)
library(randomForest)
library(localModel)

data('HR')

set.seed(17)
mrf <- randomForest(status ~., data = HR, ntree = 100)
explainer <- explain(mrf, 
                     HR[, -6],
                     predict_function = function(x, y) predict(x, y, type = "prob"))
new_observation <- HR[10, -6]
new_observation

## ----explanation--------------------------------------------------------------
model_lok <- individual_surrogate_model(explainer, new_observation, 
                                        size = 500, seed = 17)
plot(model_lok)
plot(model_lok, geom = "bar")

Try the localModel package in your browser

Any scripts or data that you put into this service are public.

localModel documentation built on Sept. 14, 2021, 5:12 p.m.