create_grouped_data_partition | R Documentation |
group_partitions
is NULL
, all samples from each group will go into
either the training set or the testing set.
Otherwise, the groups will be split according to group_partitions
Split into train and test set while splitting by groups.
When group_partitions
is NULL
, all samples from each group will go into
either the training set or the testing set.
Otherwise, the groups will be split according to group_partitions
create_grouped_data_partition(
groups,
group_partitions = NULL,
training_frac = 0.8
)
groups |
Vector of groups to keep together when splitting the data into
train and test sets. If the number of groups in the training set is larger
than |
group_partitions |
Specify how to assign |
training_frac |
Fraction of data for training set (default: |
vector of row indices for the training set
Zena Lapp, zenalapp@umich.edu
Kelly Sovacool, sovacool@umich.edu
## Not run:
groups <- c("A", "B", "A", "B", "C", "C", "A", "A", "D")
set.seed(0)
create_grouped_data_partition(groups, training_frac = 0.8)
groups <- rep.int(c("A", "B", "C"), 3)
create_grouped_data_partition(groups,
group_partitions = list(train = c("A"), test = c("A", "B", "C"))
)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.