View source: R/plot_importance.R
plot_importance | R Documentation |
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 )
model |
A model fitted with |
fill.color |
Character vector with hexadecimal codes (e.g. "#440154FF" "#21908CFF" "#FDE725FF"), or function generating a palette (e.g. |
line.color |
Character string, color of the line produced by |
verbose |
Logical, if |
A ggplot.
print_importance()
, get_importance()
if(interactive()){ #loading example data 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) }
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.