plot.Shapley: Plot Shapley

View source: R/Shapley.R

plot.ShapleyR Documentation

Plot Shapley

Description

plot.Shapley() plots the Shapley values - the contributions of feature values to the prediction.

Usage

## S3 method for class 'Shapley'
plot(object, sort = TRUE)

Arguments

object

A Shapley R6 object

sort

logical
Should the feature values be sorted by Shapley value? Ignored for multi.class output.

Value

ggplot2 plot object

See Also

Shapley

Examples

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

# Then we explain the first instance of the dataset with the Shapley method:
x.interest <- X[1, ]
shapley <- Shapley$new(mod, x.interest = x.interest)
plot(shapley)

## End(Not run)

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