Learn R Programming

Rborist (version 0.1-1)

predict.Rborist: predict method for Rborst

Description

Prediction and test using Rborist.

Usage

"predict"(object, newdata, yTest=NULL, quantVec=NULL, quantiles = !is.null(quantVec), qBin = 5000, ctgCensus = "votes", ...)

Arguments

object
an object of class Rborist, created from a previous invocation of the command Rborist to train.
newdata
a design matrix containing new data, with the same signature of predictors as in the training command.
yTest
if specfied, a response vector against which to test the new predictions.
quantVec
a vector of quantiles to predict.
quantiles
whether to predict quantiles.
qBin
bin size for quantile etimation. Performance scales with bin size. Smaller bins sacrifice precision.
ctgCensus
whether/how to summarize per-category predictions. "votes" specifies the number of trees predicting a given class. "prob" specifies a normalized, probabilistic summary.
...
not currently used.

Value

PredictReg
a list of prediction results for regression:yPred a vector containing the predicted response.qPred a matrix containing the prediction quantiles, if requested.
PredictCtg
a list of validation results for classification:yPred a vector containing the predicted response.census a matrix of predictions, by category.prob a matrix of prediction probabilities by category, if requested.

See Also

Rborist

Examples

Run this code
## Not run: 
#   # Regression example:
#   nRow <- 5000
#   x <- data.frame(replicate(6, rnorm(nRow)))
#   y <- with(x, X1^2 + sin(X2) + X3 * X4) # courtesy of S. Welling.
#   rb <- Rborist(x,y)
# 
# 
#   # Performs separate prediction on new data:
#   xx <- data.frame(replace(6, rnorm(nRow)))
#   pred <- predict(rb, xx)
#   yPred <- pred$yPred
# 
# 
#   # Performs separate prediction, using original response as test
#   # vector:
#   pred <- predict(rb, xx, y)
#   mse <- pred$mse
#   rsq <- pred$rsq
# 
# 
#   # Performs separate prediction with (default) quantiles:
#   pred <- predict(rb, xx, quantiles="TRUE")
#   qPred <- pred$qPred
# 
# 
#   # Performs separate prediction with deciles:
#   pred <- predict(rb, xx, quantVec = seq(0.1, 1.0, by = 0.10))
#   qPred <- pred$qPred
# 
# 
#   # Performs separate quantile prediction with high binning factor:
#   pred <- predict(rb, xx, qBin=20000, quantiles="TRUE")
#   qPred <- pred$pPred
# 
# 
#   # Classification examples:
#   data(iris)
#   rb <- Rborist(iris[-5], iris[5])
# 
# 
#   # Generic prediction using training set.
#   # Census as (default) votes:
#   pred <- predict(rb, iris[-5])
#   yPred <- pred$yPred
#   census <- pred$census
# 
# 
#   # As above, but validation census to report class probabilities:
#   pred <- predict(rb, iris[-5], ctgCensus="prob")
#   prob <- pred$prob
# 
# 
#   # As above, but with training reponse as test vector:
#   pred <- predict(rb, iris[-5], iris[5], ctgCensus = "prob")
#   prob <- pred$prob
#   conf <- pred$confusion
#   misPred <- pred$misPred
# ## End(Not run)

Run the code above in your browser using DataLab