# predict.drf: Predict with a drf forest In drf: Distributional Random Forests

## Description

Predict with a drf forest

## Usage

 ``` 1 2 3 4 5 6 7 8 9 10``` ```## 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 `function(y) y` is used. `functional` which type of statistical functional. One option between: "mean"the conditional mean, the returned value is a list containing a matrix `mean` of size `n` x `f`, where `n` denotes the number of observation in `newdata` and `f` the dimension of the `transformation`. "sd"the conditional standard deviation, the returned value is a list containing a matrix `sd` of size `n` x `f`, where `n` denotes the number of observation in `newdata` and `f` the dimension of the `transformation`. "quantile"the conditional quantiles, the returned value is a list containing an array `quantile` of size `n` x `f` x `q`, where `n` denotes the number of observation in `newdata`, `f` the dimension of the `transformation` and `q` the number of desired quantiles. "cor"the conditional correlation, the returned value is a list containing an array `cor` of size `n` x `f` x `f`, where `n` denotes the number of observation in `newdata`, `f` the dimension of the `transformation`. "cov"the conditional covariance, the returned value is a list containing an array `cor` of size `n` x `f` x `f`, where `n` denotes the number of observation in `newdata`, `f` the dimension of the `transformation`. "normalPredictionScore"a prediction score based on an asymptotic normality assumption, the returned value is a list containing a list of functions `normalPredictionScore` of size `n`, where `n` denotes the number of observation in `newdata`. Here the transformation should be uni-dimensional. "custom"a custom function provided by the user, the returned value is a list containing a matrix `custom` of size `n` x `f`, where `n` denotes the number of observation in `newdata` and `f` the dimension of the output of the function `custom.functional`. "MQ"multivariate quantiles, return a list containing a matrix of the inputed ranks u (that should be provided as an argument of the predict function) along with a list of the different corresponding MQ (same size as u). `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 `functional` is set to "custom". This should be a function `f(y,w)` using the training response matrix `y` and the weights `w` at a single testing point. `...` additional parameters.

## Value

a list containing an entry with the same name as the functional selected.

## Examples

 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29``` ```# 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") ```

drf documentation built on March 29, 2021, 5:07 p.m.