KEY
- Type of groupsINSTANCE
- Type of instancespublic class GroupedKFold<KEY,INSTANCE> extends Object implements CrossValidator<GroupedDataset<KEY,ListDataset<INSTANCE>,INSTANCE>>
All the instances are split into k subsets. The validation data in each iteration is one of the subsets, whilst the training data is the remaindering subsets. The subsets are not guaranteed to have any particular balance of groups as the splitting is completely random; however if there is the same number of instances per group, then the subsets should be balanced on average. A particular fold could potentially have no training or validation data for a particular class.
Setting the number of splits to be equal to the number of total instances is
equivalent to LOOCV. If LOOCV is the aim, the GroupedLeaveOneOut
class is a more efficient implementation than this class.
Constructor and Description |
---|
GroupedKFold(int k)
Construct the
GroupedKFold with the given number of folds. |
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 GroupedKFold(int k)
GroupedKFold
with the given number of folds.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