KEY
- Type of groupsINSTANCE
- Type of instancespublic class StratifiedGroupedKFold<KEY,INSTANCE> extends Object implements CrossValidator<GroupedDataset<KEY,ListDataset<INSTANCE>,INSTANCE>>
This implementation randomly splits the data in each group into K non-overlapping subsets. The number of folds, K, is set at the size of the smallest group if it is bigger; this ensures that each fold will contain at least one training and validation example for each group, and that the relative distribution of instances per group for each fold is approximately the same as for the full dataset.
Constructor and Description |
---|
StratifiedGroupedKFold(int k)
Construct a
StratifiedGroupedKFold with the given target number
of folds, K. |
Modifier and Type | Method and Description |
---|---|
CrossValidationIterable<GroupedDataset<KEY,ListDataset<INSTANCE>,INSTANCE>> |
createIterable(GroupedDataset<KEY,ListDataset<INSTANCE>,INSTANCE> data)
Create the iterable from the dataset.
|
String |
toString() |
public StratifiedGroupedKFold(int k)
StratifiedGroupedKFold
with the given target number
of folds, K. If a group in the dataset has fewer than K instances, then
the number of folds will be reduced to the number of instances.k
- the target number of folds.public CrossValidationIterable<GroupedDataset<KEY,ListDataset<INSTANCE>,INSTANCE>> createIterable(GroupedDataset<KEY,ListDataset<INSTANCE>,INSTANCE> data)
CrossValidator
createIterable
in interface CrossValidator<GroupedDataset<KEY,ListDataset<INSTANCE>,INSTANCE>>
data
- the dataset