Measure how often observations share terminal nodes in a fitted forest, within one dataset or between two datasets. This is an experimental feature; the available modes and their data requirements are described below.
Usage
forest.kernel(
object,
X1 = NULL,
X2 = NULL,
vs.train = FALSE,
oob = FALSE,
verbose = FALSE,
...
)Arguments
- object
A fitted RLT object.
- X1
The dataset for prediction. This calculates an \(n_1 \times n_1\) kernel matrix of
X1.- X2
The dataset for reference/training. If
X2is supplied, then calculate an \(n_1 \times n_2\) kernel matrix. Ifvs.trainis used, then this must be the original training data.- vs.train
Include each reference observation's in-bag multiplicity in its leaf-sharing count.
X2must be the original training data in its original row order. To use this feature, you must specifyresample.track = TRUEinparam.controlwhen fitting the forest- oob
Logical. If
TRUE, compute the OOB (out-of-bag) self-kernel, which counts co-occurrence only from trees where both observations are OOB. Each contributing tree was fitted without either observation in the pair. Requiresresample.track = TRUEandX1to be the original training data.X2must beNULL(OOB kernel is defined for self-kernel only). The returned list contains three matrices:Kernel(normalized co-occurrence in \([0,1]\) whereN > 0),N(number of trees where both are OOB), andC(number of trees where both are OOB and share a leaf). Entries withN = 0are returned as zero; inspectNto distinguish these unsupported pairs from observed zero leaf sharing.- verbose
Whether fitting should be printed.
- ...
... Additional arguments.
Value
A list containing the kernel matrix. For oob = TRUE, the list also
contains N (OOB co-occurrence count) and C (OOB leaf-sharing count).
Details
Ordinary kernel entries count trees in which two observations share a terminal node. They are not normalized observation contributions to a forest prediction. The training-data mode includes in-bag multiplicities; the OOB mode instead normalizes by the number of trees eligible for each pair.