Learn R Programming

Rborist (version 0.3-7)

forestWeight: Meinshausen forest weights

Description

Normalized observation counts across a prediction set.

Usage

# S3 method for default
forestWeight(objTrain, prediction, sampler=objTrain$sampler,
nThread=0, verbose = FALSE, ...)

Value

a numeric matrix having rows equal to the Meinshausen weight of each new datum.

Arguments

objTrain

an object of class rfArb, created from a previous invocation of the command Rborist or rfArb to train.

prediction

an object of class SummaryReg or SummaryCtg obtained from prediction using objTrain and argument indexing=TRUE.

sampler

an object of class Sampler, as documented for command of the same name.

nThread

specifies a prefered thread count.

verbose

whether to output progress of weighting.

...

not currently used.

Author

Mark Seligman at Suiji.

References

Meinshausen, N. (2016) Quantile Random Forests. Journal of Machine Learning Research 17(1), 1-68.

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)


  newdata <- data.frame(replace(6, rnorm(nRow)))

  # Performs separate prediction on new data, saving indices:
  pred <- predict(rb, newdata, indexing=TRUE)
  weights <- forestWeight(rb, pred)

  obsIdx <- 215 # Arbitrary observation index (zero-based row number)

  # Inner product should equal prediction, modulo numerical vagaries:
  yPredApprox <- weights[obsIdx,] %*% y
  print((yPredApprox - pred$yPred[obsIdx])/yPredApprox) 
}

Run the code above in your browser using DataLab