predict.drf {drf} | R Documentation |
Predict with a drf forest
Description
Predict with a drf forest
Usage
## S3 method for class 'drf'
predict(
object,
newdata = NULL,
transformation = NULL,
functional = NULL,
num.threads = NULL,
custom.functional = function(y, w) apply(y, 2, sum(y * w)),
...
)
Arguments
object |
The trained drf forest. |
newdata |
Points at which predictions should be made. If NULL, makes out-of-bag predictions on the training set instead (i.e., provides predictions at Xi using only trees that did not use the i-th training example). Note that this matrix (or vector) should have the number of columns as the training matrix, and that the columns must appear in the same order. |
transformation |
a function giving a transformation of the responses, by default if NULL, the identity |
functional |
which type of statistical functional. One option between:
|
num.threads |
Number of threads used in training. If set to NULL, the software automatically selects an appropriate amount. |
custom.functional |
a function giving the custom functional when |
... |
additional parameters. |
Value
a list containing an entry with the same name as the functional selected.
Examples
# Train a distributional random forest with CART splitting rule.
n <- 100
p <- 2
X <- matrix(rnorm(n * p), n, p)
Y <- X + matrix(rnorm(n * p), ncol=p)
drf.forest <- drf(X = X, Y = Y)
# Predict conditional correlation.
X.test <- matrix(0, 101, p)
X.test[, 1] <- seq(-2, 2, length.out = 101)
cor.pred <- predict(drf.forest, X.test, functional = "cor")
# Predict on out-of-bag training samples.
cor.oob.pred <- predict(drf.forest, functional = "cor")
# Train a distributional random forest with "FourierMMD" splitting rule.
n <- 100
p <- 2
X <- matrix(rnorm(n * p), n, p)
Y <- X + matrix(rnorm(n * p), ncol=p)
drf.forest <- drf(X = X, Y = Y, splitting.rule = "FourierMMD", num.features = 10)
# Predict conditional correlation.
X.test <- matrix(0, 101, p)
X.test[, 1] <- seq(-2, 2, length.out = 101)
cor.pred <- predict(drf.forest, X.test, functional = "cor")
# Predict on out-of-bag training samples.
cor.oob.pred <- predict(drf.forest, functional = "cor")