Plots variable importance scores of rf(), rf_repeat(), and rf_spatial() models. Distributions of importance scores produced with rf_repeat() are plotted using ggplot2::geom_violin, which shows the median of the density estimate rather than the actual median of the data. However, the violin plots are ordered from top to bottom by the real median of the data to make small differences in median importance easier to spot. Ths function does not plot the result of rf_importance() yet, but you can find it under model$importance$cv.per.variable.plot.

plot_importance(
model,
fill.color = viridis::viridis(
100,
option = "F",
direction = -1,
alpha = 1,
end = 0.9
),
line.color = "white",
verbose = TRUE
)

## Arguments

model A model fitted with rf(), rf_repeat(), or rf_spatial(), or a data frame with variable importance scores (only for internal use within the package functions). Character vector with hexadecimal codes (e.g. "#440154FF" "#21908CFF" "#FDE725FF"), or function generating a palette (e.g. viridis::viridis(100)). Default: viridis::viridis(100, option = "F", direction = -1, alpha = 0.8, end = 0.9) Character string, color of the line produced by ggplot2::geom_smooth(). Default: "white" Logical, if TRUE, the plot is printed. Default: TRUE

## Value

A ggplot.

print_importance(), get_importance()

## Examples

if(interactive()){

data(plant_richness_df)
data(distance_matrix)

#fitting a random forest model
rf.model <- rf(
data = plant_richness_df,
dependent.variable.name = "richness_species_vascular",
predictor.variable.names = colnames(plant_richness_df)[5:21],
distance.matrix = distance_matrix,
distance.thresholds = 0,
n.cores = 1,
verbose = FALSE
)

#plotting variable importance scores
plot_importance(model = rf.model)

}