broken.default {breakDown}R Documentation

Create the model agnostic broken object

Description

Create the model agnostic broken object

Usage

## Default S3 method:
broken(model, new_observation, data, direction = "up", ...,
  baseline = 0, predict.function = predict)

Arguments

model

a ranger model

new_observation

a new observation with columns that corresponds to variables used in the model

data

the original data used for model fitting, should have same collumns as the 'new_observation'.

direction

either 'up' or 'down' determined the exploration strategy

...

other parameters

baseline

the orgin/baseline for the breakDown plots, where the rectangles start. It may be a number or a character "Intercept". In the latter case the orgin will be set to model intercept.

predict.function

function that will calculate predictions out of model. It shall return a single numeric value per observation. For classification it may be a probability of the default class.

Value

an object of the broken class

Examples

## Not run: 
library(breakDown)
library(randomForest)
library(ggplot2)
set.seed(1313)
model <- randomForest(factor(left)~., data = HR_data, family = "binomial", maxnodes = 5)
predict.function <- function(model, new_observation)
      predict(model, new_observation, type="prob")[,2]
predict.function(model, HR_data[11,-7])
explain_1 <- broken(model, HR_data[11,-7], data = HR_data[,-7],
predict.function = predict.function, direction = "down")
explain_1
plot(explain_1) + ggtitle("breakDown plot (direction=down) for randomForest model")

## End(Not run)

[Package breakDown version 0.1.5 Index]