library(isotree)
set.seed(123)
X <- matrix(rnorm(100 * 3), nrow = 100)
model <- isolation.forest(X, ndim=1, max_depth=3, ntrees=2, nthreads=1)
model_as_graphviz <- isotree.to.graphviz(model)
# These can be parsed and plotted with library 'DiagrammeR'
if (require("DiagrammeR")) {
# first tree
DiagrammeR::grViz(model_as_graphviz[[1]])
DiagrammeR::grViz(model_as_graphviz[[1]])
}
Run the code above in your browser using DataLab