ciu.plots.beeswarm: Create beeswarm-type visualisation.

View source: R/ciu.plots.R

ciu.plots.beeswarmR Documentation

Create beeswarm-type visualisation.

Description

Create beeswarm-type visualisation.

Usage

ciu.plots.beeswarm(data, target.columns = c("Feature", "CI", "Norm.Value"))

Arguments

data

A data.frame with CIU (or other) results that has to have at least the columns:

  • Feature: Feature name.

  • The CI, CU, influence, whatever actual values to plot.

  • Norm.Value: Normalized feature values. This can be omitted. Such a data.frame is returned by ciu.explain.long.data.frame, from which the "non-relevant" columns have to be removed, however (see examples).

target.columns

Character vector with names of the columns to use:

  • Column with feature names.

  • Column with actual importance/influence/whatever values to plot.

  • Column with normalized values to use for determining color. If omitted, then the plot is produced without the colours. Default: c("Feature", "CI", "Norm.Value").

Value

ggplot object

Examples

## Not run: 
# Boston data set with GBM model.
library(MASS)
library(caret)
library(ggbeeswarm)
kfoldcv <- trainControl(method="cv", number=10)
gbm <- caret::train(medv ~ ., Boston, method="gbm", trControl=kfoldcv)
ciu <- ciu.new(gbm, medv~., Boston)
df <- ciu.explain.long.data.frame(ciu)
p <- ciu.plots.beeswarm(df); print(p)
p <- ciu.plots.beeswarm(df, c("Feature","CU","Norm.Value")); print(p)
p <- ciu.plots.beeswarm(df, c("Feature","Influence","Norm.Value")); print(p)

# Plot without normalized values.
p <- ciu.plots.beeswarm(df, c("Feature","Influence")); print(p)

# Shapley value-compatible reference value
mean.utility <- (mean(Boston$medv)-min(Boston$medv))/(max(Boston$medv)-min(Boston$medv))
df <- ciu.explain.long.data.frame(ciu, neutral.CU=mean.utility)
p <- ciu.plots.beeswarm(df, c("Feature","Influence","Norm.Value")); print(p)

## End(Not run)

ciu documentation built on June 17, 2025, 1:08 a.m.