View source: R/get_importance_local.R
| get_importance_local | R Documentation |
Extracts local (case-specific) variable importance scores from models fitted with rf(), rf_repeat(), or rf_spatial().
get_importance_local(model)
model |
Model object from |
Local importance measures how much each predictor contributes to predictions for individual observations, unlike global importance which summarizes contributions across all observations. This can reveal spatial or contextual patterns in variable influence.
Data frame with one row per observation and one column per predictor variable. Each cell contains the local importance score for that variable at that observation.
rf(), rf_repeat(), rf_spatial(), get_importance(), plot_importance(), print_importance()
Other model_info:
get_evaluation(),
get_importance(),
get_moran(),
get_performance(),
get_predictions(),
get_residuals(),
get_response_curves(),
get_spatial_predictors(),
print.rf(),
print_evaluation(),
print_importance(),
print_moran(),
print_performance()
data(plants_rf)
# Extract local importance scores
local_imp <- get_importance_local(plants_rf)
# View structure: rows = observations, columns = variables
dim(local_imp)
head(local_imp)
# Find which variable is most important for first observation
colnames(local_imp)[which.max(local_imp[1, ])]
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.