forestWeight | R Documentation |
Normalized observation counts across a prediction set.
## Default S3 method:
forestWeight(objTrain, prediction, sampler=objTrain$sampler,
nThread=0, verbose = FALSE, ...)
objTrain |
an object of class |
prediction |
an object of class |
sampler |
an object of class |
nThread |
specifies a prefered thread count. |
verbose |
whether to output progress of weighting. |
... |
not currently used. |
a numeric matrix having rows equal to the Meinshausen weight of each new datum.
Mark Seligman at Suiji.
Rborist
## 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)
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 (row number)
# Inner product should equal prediction, modulo numerical vagaries:
yPredApprox <- weights[obsIdx,] %*% y
print((yPredApprox - pred$yPred[obsIdx])/yPredApprox)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.