R/RunOOB.R

Defines functions RunOOB

Documented in RunOOB

#' Predict class labels on out-of-bag observations using a single tree.
#'
#' This is the base function called by OOBPredict.
#'
#' @param X an n sample by d feature matrix (preferable) or data frame which was used to train the provided forest.
#' @param tree a tree from a forest returned by RerF.
#'
#' @return out prediction matrix used by OOBPredict
#'

RunOOB <- function(X, tree) {
  n.all <- nrow(X)
  num.classes <- ncol(tree$ClassProb)

  # Get OOB samples
  X <- X[tree$ind, , drop = FALSE]

  # Predict OOB samples
  predictions <- RunPredict(X, tree)

  # Create a matrix for all of samples
  out <- matrix(0, nrow = n.all, ncol = num.classes)
  out[tree$ind, ] <- predictions
  return(out)
}

Try the rerf package in your browser

Any scripts or data that you put into this service are public.

rerf documentation built on May 2, 2019, 8:16 a.m.