
Last chance! 50% off unlimited learning
Sale ends in
Gets estimates of E[Y|X=x] using a trained regression forest.
# S3 method for regression_forest
predict(object, newdata = NULL,
num.threads = NULL, estimate.variance = FALSE, ...)
The trained forest.
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).
Number of threads used in training. If set to NULL, the software automatically selects an appropriate amount.
Whether variance estimates for hattau(x) are desired (for confidence intervals).
Additional arguments (currently ignored).
A vector of predictions.
# NOT RUN {
# Train a standard regression forest.
n = 50; p = 10
X = matrix(rnorm(n*p), n, p)
Y = X[,1] * rnorm(n)
r.forest = regression_forest(X, Y)
# Predict using the forest.
X.test = matrix(0, 101, p)
X.test[,1] = seq(-2, 2, length.out = 101)
r.pred = predict(r.forest, X.test)
# Predict on out-of-bag training samples.
r.pred = predict(r.forest)
# Predict with confidence intervals; growing more trees is now recommended.
r.forest = regression_forest(X, Y, num.trees = 100)
r.pred = predict(r.forest, X.test, estimate.variance = TRUE)
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab