R: Predict with a custom forest.

predict.custom_forest {grf} | R Documentation

## Predict with a custom forest.

### Description

Predict with a custom forest.

### Usage

    ## S3 method for class 'custom_forest'
    predict(object, newdata = NULL,
      num.threads = NULL, ...)

### Arguments

`object` | The trained 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 should have the number of columns as the training matrix, and that the columns must appear in the same order.
`num.threads` | Number of threads used in training. If set to NULL, the software automatically selects an appropriate amount.
`...` | Additional arguments (currently ignored).

### Value

Vector of predictions.

### Examples

    ## Not run:
    # Train a custom forest.
    n = 50; p = 10
    X = matrix(rnorm(n*p), n, p)
    Y = X[,1] * rnorm(n)
    c.forest = custom_forest(X, Y)

    # Predict using the forest.
    X.test = matrix(0, 101, p)
    X.test[,1] = seq(-2, 2, length.out = 101)
    c.pred = predict(c.forest, X.test)

    ## End(Not run)

[Package grf version 0.10.3 Index]