ciu.plots.beeswarm | R Documentation |
Create beeswarm-type visualisation.
ciu.plots.beeswarm(data, target.columns = c("Feature", "CI", "Norm.Value"))
data |
A data.frame with CIU (or other) results that has to have at least the columns:
|
target.columns |
Character vector with names of the columns to use:
|
ggplot
object
## 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.