presample: Forest-wide Observation Sampling

View source: R/presample.R

presampleR Documentation

Forest-wide Observation Sampling

Description

Observations sampled for each tree to be trained. In the case of the Random Forest algorithm, this is the bag.

Usage

## Default S3 method:
presample(y,
                            rowWeight = NULL,
                            nSamp = 0,
                            nTree = 500,
                            withRepl =  TRUE,
                            verbose = FALSE,
                            ...)

Arguments

y

A vector to be sampled, typically the response.

rowWeight

Per-observation sampling weights. Default is uniform.

nSamp

Size of sample draw. Default draws y length.

nTree

Number of samples to draw.

withRepl

true iff sampling is with replacement.

verbose

true iff tracing execution.

...

not currently used.

Value

an object of class Sampler consisting of:

yTrain

The sampled vector.

nSamp

The sample sizes drawn.

nTree

The number of independent samples.

samples

A packed data structure encoding the observation index and corresponding sample count.

hash

A hashed digest of the data items.

Examples

  ## Not run: 
    y <- runif(1000)

    # Samples with replacement, 500 vectors of length 1000:
    ps <- presample(y)

    # Samples without replacement, 250 vectors of length 500:
    ps2 <- presample(y, nTree=250, nSamp=500, withRepl = FALSE)
  
## End(Not run)

Rborist documentation built on July 26, 2023, 5:32 p.m.