Description Usage Arguments Value Examples
Predicts the classification of samples using a trained forest.
1 2 |
X |
an n by d numeric matrix (preferable) or data frame. The rows correspond to observations and columns correspond to features of a test set, which should be different from the training set. |
forest |
a forest trained using the RerF function. |
OOB |
if TRUE then run predictions using out-of-bag samples. |
num.cores |
the number of cores to use while training. If NumCores=0 then 1 less than the number of cores reported by the OS are used. (NumCores=0) |
Xtrain |
an n by d numeric matrix (preferable) or data frame. This should be the same data matrix/frame used to train the forest, and is only required if RerF was called with rank.transform = TRUE. (Xtrain=NULL) |
aggregate.output |
if TRUE then the tree predictions are aggregated weighted by their probability estimates. Otherwise, the individual tree probabilities are returned. (aggregate.output=TRUE) TODO: Remove option for aggregate output? Only options for returning aggregate predictions or probabilities |
output.scores |
if TRUE then predicted class scores (probabilities) for each observation are returned rather than class labels. (output.scores = FALSE) |
predictions an n length vector of predictions
1 2 3 4 5 6 7 8 | library(rerf)
trainIdx <- c(1:40, 51:90, 101:140)
X <- as.matrix(iris[, 1:4])
Y <- as.numeric(iris[, 5])
forest <- RerF(X[trainIdx, ], Y[trainIdx], num.cores = 1L, rank.transform = TRUE)
# Using a set of samples with unknown classification
predictions <- Predict(X[-trainIdx, ], forest, num.cores = 1L, Xtrain = X[trainIdx, ])
error.rate <- mean(predictions != Y[-trainIdx])
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.