Create/coerce and print resampling objects, e.g., partitionings or boostrap samples derived from a data set.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
depending on the function/method, a list or a vector of type factor defining a partitioning of the dataset.
currently not used.
object of class
resampling object is a list of lists defining a set of
training and test samples.
In the case of
k-fold cross-validation partitioning, for example,
resampling object would be of length
k lists. Each of these
k lists defines a training
set of size
n is the overall sample size), and
a test set of size
resampling object does, however, not contain the data itself, but
only indices between
n identifying the selection
Another example is bootstrap resampling. represampling_bootstrap
oob = TRUE generates
with indices of a bootstrap sample in the
train component and indices
of the out-of-bag sample in the test component (see Examples below).
as.resampling.factor: For each factor level of the input variable,
as.resampling.factor determines the indices of samples in this level
(= test samples) and outside this level (= training samples). Empty levels of
object are dropped without warning.
as.resampling_list checks if the list in
object has a valid
resampling object structure (with components
test etc.) and assigns the class attribute
as.resampling methods: An object of class
represampling, partition_cv, partition_kmeans, represampling_bootstrap, etc.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
data(ecuador) # Muenchow et al. (2012), see ?ecuador # Partitioning by elevation classes in 200 m steps: parti <- factor( as.character( floor( ecuador$dem / 200 ) ) ) smp <- as.resampling(parti) summary(smp) # Compare: summary(parti) # k-fold (non-spatial) cross-validation partitioning: parti <- partition_cv(ecuador) parti <- parti[] # the first (and only) resampling object in parti # data corresponding to the test sample of the first fold: str( ecuador[ parti[]$test , ]) # the corresponding training sample - larger: str( ecuador[ parti[]$train , ]) # Bootstrap training sets, out-of-bag test sets: parti <- represampling_bootstrap(ecuador, oob = TRUE) parti <- parti[] # the first (and only) resampling object in parti # out-of-bag test sample: approx. one-third of nrow(ecuador): str( ecuador[ parti[]$test , ]) # bootstrap training sample: same size as nrow(ecuador): str( ecuador[ parti[]$train , ])
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.