View source: R/07_shi_ranger_one_tree.R
shi_ranger_one_tree | R Documentation |
Given a tree, this function computes dissimilarities between individuals based on the approach of Shi and Hovarth (2006). That is, dissimilarity between two individuals is increased to one if they don't belong to the same terminal nodes
shi_ranger_one_tree(tree_index = 1, predictions, init_dist = 0)
tree_index |
[ |
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) pred.iris <- predict(rg.iris, data = iris.test, type = "terminalNodes") shi_dist <- shi_ranger_one_tree(tree_index = 1, predictions = pred.iris)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.