# Set seed
set.seed(1)
# Split training and test
trn <- sample(1:nrow(iris), 100)
tst <- setdiff(1:nrow(iris), trn)
# Train RF. You can also use RF variants, such as the Adversarial Random
# Forests (ARF).
rf <- ranger::ranger(Species ~ ., data = iris[trn, ], num.trees=50)
# Learn the encodings, which are found using diffusion maps.
emap <- encode(rf, iris[trn, ], k=2)
# Embed test points
emb <- predict(emap, rf, iris[tst, ])
Run the code above in your browser using DataLab