Visualisations for Model Ensembles

Displays for model fits of multiple models and their ensembles. For classification models, the plots are heatmaps, for regression, scatterplots.


R-CMD-check

ensModelVis

The goal of ensModelVis is to display model fits for multiple models and their ensembles.

Installation

You can install the development version of ensModelVis from GitHub with:

# install.packages("devtools")
devtools::install_github("domijan/ensModelVis")

Example

This is a basic example:

library(ensModelVis)

data(iris)
if (require("MASS")) {
  lda.model <- lda(Species ~ ., data = iris)
  lda.pred <- predict(lda.model)
}
#> Loading required package: MASS
if (require("ranger")) {
  ranger.model <- ranger(Species ~ ., data = iris, mtry = 1)
  ranger.pred <- predict(ranger.model, iris)
  ranger.model2 <-
    ranger(Species ~ .,
           data = iris,
           mtry = 4,
           num.trees = 10)
  ranger.pred2 <- predict(ranger.model2, iris)
}
#> Loading required package: ranger


plot_ensemble(
  iris$Species,
  data.frame(
    LDA = lda.pred$class,
    RF = ranger.pred$predictions,
    RF2 = ranger.pred2$predictions
  )
)


plot_ensemble(
  iris$Species,
  data.frame(
    LDA = lda.pred$class,
    RF = ranger.pred$predictions,
    RF2 = ranger.pred2$predictions
  ),
  incorrect = TRUE
)

if (require("ranger")) {
  ranger.model <- ranger(Species ~ ., data = iris, mtry = 1, probability = TRUE)
  ranger.prob <- predict(ranger.model, iris)
   ranger.model2 <-
    ranger(Species ~ .,
           data = iris,
           mtry = 4,
           num.trees = 10,
           probability = TRUE)
  ranger.prob2 <- predict(ranger.model2, iris)
}

plot_ensemble(
  iris$Species,
  data.frame(LDA = lda.pred$class,
             RF = ranger.pred$predictions,
             RF2 = ranger.pred2$predictions),
  tibble_prob = data.frame(
    LDA = apply(lda.pred$posterior, 1, max),
    RF = apply(ranger.prob$predictions, 1, max),
    RF2 = apply(ranger.prob2$predictions, 1, max)
  )
)

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("ensModelVis")

0.2.0 by Katarina Domijan, 9 months ago


https://github.com/domijan/ensModelVis


Report a bug at https://github.com/domijan/ensModelVis/issues


Browse source code at https://github.com/cran/ensModelVis


Authors: Katarina Domijan [aut, cre] (ORCID:


Documentation:   PDF Manual  


MIT + file LICENSE license


Imports dplyr, forcats, ggplot2, rlang, tidyr

Suggests discrim, glmnet, kernlab, knitr, MASS, nnet, ranger, rmarkdown, stacks, stringr, tidymodels


See at CRAN