Rborist (version 0.2-3)

predict.Rborist: predict method for Rborst

Description

Prediction and test using Rborist.

Usage

# S3 method for Rborist
predict(object, newdata, yTest=NULL, quantVec=NULL,
quantiles = !is.null(quantVec), ctgCensus = "votes", oob = FALSE,
nThread = 0, verbose = FALSE, ...)

Value

a list containing either of the two prediction containers:

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.

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.

ctgCensus

whether/how to summarize per-category predictions. "votes" specifies the number of trees predicting a given class. "prob" specifies a normalized, probabilistic summary.

oob

whether prediction is restricte to out-of-bag samples.

nThread

suggests ans OpenMP-style thread count. Zero denotes default processor setting.

verbose

whether to output progress of prediction.

...

not currently used.

Author

Mark Seligman at Suiji.

See Also

Rborist

Examples

Run this code
if (FALSE) {
  # 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


  # 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
}

Run the code above in your browser using DataCamp Workspace