GroupKFoldCrossValidator<T, TInput, TOutput>

Models & Types ยท AiDotNet.CrossValidators

Implements a Group K-Fold cross-validation strategy for model evaluation.

Inheritance: CrossValidatorBase<T, TInput, TOutput> โ†’ GroupKFoldCrossValidator<T, TInput, TOutput>

For Beginners

Group K-Fold cross-validation is useful when your data has natural groupings.

What this class does:

  • Splits your data into k parts (folds) based on group identifiers
  • Ensures that all data points from the same group stay together
  • Uses each part once for testing and the rest for training
  • Repeats this process k times, so each part gets a chance to be the test set
  • Calculates how well your model performs on average across all these tests

This is particularly useful when:

  • Your data has natural groups (e.g., multiple measurements from the same person)
  • You want to ensure that related data points are not split between training and testing sets

How It Works

This class provides a Group K-Fold cross-validation implementation, where the data is split into k folds based on a group identifier. This ensures that all samples from the same group are in the same fold.

Constructors

Constructor Summary
GroupKFoldCrossValidator(int[] groups, CrossValidationOptions options) Initializes a new instance of the GroupKFoldCrossValidator class.

Methods

Method Summary
CrossValidationResult<T, TInput, TOutput> Validate(IFullModel<T, TInput, TOutput> model, TInput X, TOutput y, IOptimizer<T, TInput, TOutput> optimizer) Performs the group k-fold cross-validation process on the given model using the provided data and optimizer.