The goal of ensModelVis is to display model fits for multiple models and their ensembles.
You can install the development version of ensModelVis from GitHub with:
# install.packages("devtools")
::install_github("domijan/ensModelVis") devtools
This is a basic example:
library(ensModelVis)
data(iris)
if (require("MASS")) {
<- lda(Species ~ ., data = iris)
lda.model <- predict(lda.model)
lda.pred
}#> Loading required package: MASS
if (require("ranger")) {
<- ranger(Species ~ ., data = iris, mtry = 1)
ranger.model <- predict(ranger.model, iris)
ranger.pred <-
ranger.model2 ranger(Species ~ .,
data = iris,
mtry = 4,
num.trees = 10)
<- predict(ranger.model2, iris)
ranger.pred2
}#> Loading required package: ranger
plot_ensemble(
$Species,
irisdata.frame(
LDA = lda.pred$class,
RF = ranger.pred$predictions,
RF2 = ranger.pred2$predictions
) )
plot_ensemble(
$Species,
irisdata.frame(
LDA = lda.pred$class,
RF = ranger.pred$predictions,
RF2 = ranger.pred2$predictions
),incorrect = TRUE
)
if (require("ranger")) {
<- ranger(Species ~ ., data = iris, mtry = 1, probability = TRUE)
ranger.model <- predict(ranger.model, iris)
ranger.prob <-
ranger.model2 ranger(Species ~ .,
data = iris,
mtry = 4,
num.trees = 10,
probability = TRUE)
<- predict(ranger.model2, iris)
ranger.prob2
}
plot_ensemble(
$Species,
irisdata.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)
) )