rf.out.of.bag: rf.out.of.bag

rf.out.of.bagR Documentation

rf.out.of.bag

Description

It runs standard random forests with out-of-bag error estimation for both classification and regression using ranger. This is merely a wrapper that extracts relevant info from ranger output.

Usage

rf.out.of.bag(
  x,
  y,
  ntree = 500,
  verbose = FALSE,
  sparse = FALSE,
  imp_pvalues = FALSE
)

Arguments

x

Training data: data.matrix or data.frame.

y

A response vector. If a factor, classification is assumed, otherwise regression is assumed.

ntree

The number of trees.

verbose

A boolean value indicates if showing computation status and estimated runtime.

sparse

A boolean value indicates if the input matrix transformed into sparse matrix for rf modeling.

imp_pvalues

If compute both importance score and pvalue for each feature.

Details

Ranger is a fast implementation of random forests (Breiman 2001) or recursive partitioning, particularly suited for high dimensional data. Classification, regression, and survival forests are supported.

Value

Object of class rf.out.of.bag with elements including the ranger object and critical metrics for model evaluation.

Author(s)

Shi Huang

References

Wright, M. N. & Ziegler, A. (2017). ranger: A fast implementation of random forests for high dimensional data in C++ and R. Journal of Statistical Software 77:1-17.

See Also

ranger

Examples

set.seed(123)
x <- data.frame(rbind(t(rmultinom(7, 75, c(.201,.5,.02,.18,.099))),
            t(rmultinom(8, 75, c(.201,.4,.12,.18,.099))),
            t(rmultinom(15, 75, c(.011,.3,.22,.18,.289))),
            t(rmultinom(15, 75, c(.091,.2,.32,.18,.209))),
            t(rmultinom(15, 75, c(.001,.1,.42,.18,.299)))))
y<-factor(c(rep("A", 15), rep("B", 15), rep("C", 15), rep("D", 15)))
y<-factor(c(rep("A", 20), rep("B", 20), rep("C", 20)))
rf.out.of.bag(x, y, imp_pvalues=FALSE)
rf.out.of.bag(x, y, imp_pvalues=TRUE)
x_ <- data.frame(rbind(t(rmultinom(7, 7500, rep(c(.201,.5,.02,.18,.099), 1000))),
            t(rmultinom(8, 750, rep(c(.201,.4,.12,.18,.099), 1000))),
            t(rmultinom(15, 750, rep(c(.011,.3,.22,.18,.289), 1000))),
            t(rmultinom(15, 750, rep(c(.091,.2,.32,.18,.209), 1000))),
            t(rmultinom(15, 750, rep(c(.001,.1,.42,.18,.299), 1000)))))
y_<-factor(c(rep("A", 15), rep("B", 15), rep("C", 15), rep("D", 15)))
rf.out.of.bag(x_, y_, imp_pvalues=FALSE)
rf.out.of.bag(x, y_, imp_pvalues=TRUE)
y0<-factor(c(rep("old", 30), rep("young", 30)))
rf.out.of.bag(x, y0, imp_pvalues=FALSE)
rf.out.of.bag(x, y0, imp_pvalues=TRUE)
y<- 1:60
rf.out.of.bag(x, y, imp_pvalues=FALSE)

shihuang047/crossRanger documentation built on Feb. 7, 2023, 10:03 p.m.