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,
                            samplingWeight = numeric(0),
                            nSamp = 0,
                            nRep = 500,
                            withRepl =  TRUE,
                            nHoldout = 0,
                            nFold = 1,
                            verbose = FALSE,
                            nTree = 0,
                            ...)

Arguments

y

A vector to be sampled, typically the response.

samplingWeight

Per-observation sampling weights. Default is uniform.

nSamp

Size of sample draw. Default draws y length.

nRep

Number of samples to draw. Replaces deprecated nTree.

withRepl

true iff sampling is with replacement.

nHoldout

Number of observations to omit from sampling. Augmented by unobserved response values.

nFold

Number of collections into which to partition the respone.

verbose

true iff tracing execution.

nTree

Number of samples to draw. Deprecated.

...

not currently used.

Value

an object of class Sampler consisting of:

  • yTrain the sampled vector.

  • nSamp the sample sizes drawn.

  • nRep the number of independent samples.

  • nTree synonymous with nRep. Deprecated.

  • samples a packed data structure encoding the observation index and corresponding sample count.

  • hash a hashed digest of the data items.

References

Tille, Yves. Sampling algorithms. Springer New York, 2006.

Examples

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

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

    # Samples, as above, with 63 observations held out:
    ps <- presample(y, nHoldout = 63)

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


  
## End(Not run)

Rborist documentation built on April 3, 2025, 8:04 p.m.