distanceRandomForest {CaseBasedReasoning} | R Documentation |
Distance calculation based on RandomForest Proximity or Depth
Description
Distance calculation based on RandomForest Proximity or Depth
Usage
distanceRandomForest(
x,
y = NULL,
rfObject,
method = "Proximity",
threads = NULL
)
Arguments
x |
a data.frame |
y |
a second data.frame |
rfObject |
|
method |
distance calculation method, Proximity (Default) or Depth. |
threads |
number of threads to use |
Value
a dist
or a matrix object with pairwise distance of
observations in x vs y (if not null)
Examples
library(ranger)
# proximity pairwise distances
rf.fit <- ranger(Species ~ ., data = iris, num.trees = 500, write.forest = TRUE)
distanceRandomForest(x = iris[, -5], rfObject = rf.fit, method = "Proximity", threads = 1)
# depth distance for train versus test subset
set.seed(1234L)
learn <- sample(1:150, 100)
test <- (1:150)[-learn]
rf.fit <- ranger(Species ~ ., data = iris[learn, ], num.trees = 500, write.forest = TRUE)
distanceRandomForest(x = iris[learn, -5], y = iris[test, -5], rfObject = rf.fit, method = "Depth")
[Package CaseBasedReasoning version 0.3 Index]