StratifiedGroupKFoldSplitter<T>

Models & Types ยท AiDotNet.Preprocessing.DataPreparation.Splitting.GroupBased

Stratified Group K-Fold cross-validation that keeps groups together while preserving class distribution.

Inheritance: DataSplitterBase<T> โ†’ StratifiedGroupKFoldSplitter<T>

For Beginners

This combines two important concepts:

  1. Group K-Fold: Ensures all samples from the same group stay together
  2. Stratification: Maintains the proportion of each class in train/test sets

How It Works

When to Use:

  • Medical studies where patients have multiple measurements AND classes are imbalanced
  • Customer data where purchases from same customer should stay together AND you have rare categories
  • Any grouped data with classification targets where class balance matters

Constructors

Constructor Summary
StratifiedGroupKFoldSplitter(int k, int[] groups, bool shuffle, int randomSeed) Creates a new Stratified Group K-Fold splitter.

Properties

Property Summary
bool RequiresLabels { get; }
int NumSplits { get; }
string Description { get; }

Methods

Method Summary
DataSplitResult<T> Split(Matrix<T> X, Vector<T> y)
IEnumerable<DataSplitResult<T>> GetSplits(Matrix<T> X, Vector<T> y)
StratifiedGroupKFoldSplitter<T> WithGroups(int[] groups) Sets the group assignments for samples.