Learn R Programming

iml (version 0.6.0)

plot.FeatureImp: Plot Feature Importance

Description

plot.FeatureImp() plots the feature importance results of a FeatureImp object.

Usage

# S3 method for FeatureImp
plot(x, sort = TRUE, ...)

Arguments

x

A FeatureImp R6 object

sort

logical. Should the features be sorted in descending order? Defaults to TRUE.

...

Further arguments for the objects plot function

Value

ggplot2 plot object

See Also

FeatureImp

Examples

Run this code
# NOT RUN {
 
if (require("rpart")) {
# We train a tree on the Boston dataset:
data("Boston", package  = "MASS")
tree = rpart(medv ~ ., data = Boston)
y = Boston$medv
X = Boston[-which(names(Boston) == "medv")]
mod = Predictor$new(tree, data = X, y = y)

# Compute feature importances as the performance drop in mean absolute error
imp = FeatureImp$new(mod, loss = "mae")

# Plot the results directly
plot(imp)
}
# }

Run the code above in your browser using DataLab