View source: R/08_shi_ranger_forest.R
shi_ranger_forest | R Documentation |
Computes dissimilarities between individuals based on the approach of Shi and Hovarth (2006) over a forest. For each tree, dissimilarity between two individuals is increased to one if they don't belong to the same terminal nodes. Dissimilarities over the forest is obtained by summing dissimilarities obtained from each tree.
shi_ranger_forest(predictions, init_dist = 0)
predictions |
[ |
init_dist |
[ |
[matrix
] Dissimilarity matrix according to Shi and Hovarth (2006)
library(ranger) set.seed(1234) train.idx <- sample(nrow(iris), 2/3 * nrow(iris)) iris.train <- iris[train.idx, ] iris.test <- iris[-train.idx, ] rg.iris <- ranger(Species ~ ., data = iris.train, num.trees = 5) pred.iris <- predict(rg.iris, data = iris.test, type = "terminalNodes") shi_dist <- shi_ranger_forest(predictions = pred.iris)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.