distanceRandomForest: Distance calculation based on RandomForest Proximity or Depth

Description Usage Arguments Value Examples

View source: R/distance.R

Description

Distance calculation based on RandomForest Proximity or Depth

Usage

1
2
distanceRandomForest(x, y = NULL, rfObject, method = "Proximity",
  threads = NULL)

Arguments

x

a data.frame

y

a second data.frame

rfObject

ranger object

method

distance calculation method

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
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")

CaseBasedReasoning documentation built on June 12, 2018, 5:18 p.m.