The isoForest package is a simple replication of the Isolation Forests algorithm for outlier detection, and the ranger package is used to truly construct the forests. In addition, the visualization of outliers is also implemented to help better observe the prediction results.
# Development version
devtools::install_github("flystar233/isoForest")
library(isoForest)
result <- isoForest(iris)
head(result$scores)
# id average_depth anomaly_score
# <int> <dbl> <dbl>
#1 1 7.81 0.554
#2 2 7.82 0.554
#3 3 7.71 0.559
#4 4 7.69 0.559
#5 5 7.78 0.556
#6 6 7.39 0.572
result <- isoForest(iris[1:2])
anomaly_plot(result,iris[1:2],plot_type="heatmap")