Skip to content

Instantly share code, notes, and snippets.

@BenHeubl
Created February 13, 2020 16:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BenHeubl/ac732c97a074875e62d8b7d017d67dc8 to your computer and use it in GitHub Desktop.
Save BenHeubl/ac732c97a074875e62d8b7d017d67dc8 to your computer and use it in GitHub Desktop.
tut15
# ggplotting our featuer importance:
Feature_importance <- importance(model_base)
var_Importance <- data.frame(Variables = row.names(Feature_importance),
Importance = round(importance[ ,'MeanDecreaseGini'],2))
#Create ranks for variable based on importance
Rank_Importance <- var_Importance %>%
mutate(Rank = paste0('#',dense_rank(desc(Importance))))
#Relative importance of our varaibles
ggplot(Rank_Importance, aes(x = reorder(Variables, Importance),
y = Importance, fill = Importance)) + geom_bar(stat='identity') +
geom_text(aes(x = Variables, y = 0.5, label = Rank), hjust=0, vjust=0.55, size = 4, colour = 'white') +
labs(x = 'Variables') +
coord_flip()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment