NestedCrossValidator<T, TInput, TOutput>
Models & Types · AiDotNet.CrossValidators
Implements a nested cross-validation strategy for model evaluation and hyperparameter tuning.
Inheritance: CrossValidatorBase<T, TInput, TOutput> → NestedCrossValidator<T, TInput, TOutput>
For Beginners
Nested cross-validation is like a two-layer testing process for your model.
What this class does:
- Splits your data into outer folds for overall model assessment
- For each outer fold:
- Further splits the training data into inner folds for hyperparameter tuning
- Uses the inner folds to find the best hyperparameters
- Trains a model with the best hyperparameters on the full outer training set
- Evaluates this model on the outer test set
- Calculates how well your model performs on average across all outer folds
This is useful because:
- It helps you choose the best hyperparameters for your model
- It provides an unbiased estimate of your model’s performance on new data
- It helps prevent overfitting during the model selection process
How It Works
This class provides a nested cross-validation implementation, which consists of an outer loop for model assessment and an inner loop for model selection (hyperparameter tuning).
Constructors
| Constructor | Summary |
|---|---|
NestedCrossValidator(ICrossValidator<T, TInput, TOutput> outerValidator, ICrossValidator<T, TInput, TOutput> innerValidator, Func<CrossValidationResult<T, TInput, TOutput>, IFullModel<T, TInput, TOutput>> modelSelector, CrossValidationOptions options) |
Initializes a new instance of the NestedCrossValidator 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 nested cross-validation process on the given model using the provided data and optimizer. |