sample_random: Random Sampling

View source: R/trans_sample_random.R

sample_randomR Documentation

Random Sampling

Description

Train/test split and k-fold partitioning by simple random sampling.

Usage

sample_random()

Details

This is the simplest partitioning strategy in daltoolbox. It is a good starting point when the dataset is reasonably balanced and the user wants to understand the train/test workflow before moving to stratified or more specialized sampling schemes.

Value

An object of class sample_random.

References

Kohavi, R. (1995). A Study of Cross-Validation and Bootstrap for Accuracy Estimation and Model Selection. IJCAI.

Examples

# using random sampling
sample <- sample_random()
tt <- train_test(sample, iris)

# distribution of train
table(tt$train$Species)

# preparing dataset into four folds
folds <- k_fold(sample, iris, 4)

# distribution of folds
tbl <- NULL
for (f in folds) {
  tbl <- rbind(tbl, table(f$Species))
}
head(tbl)

daltoolbox documentation built on Nov. 23, 2026, 9:08 a.m.