TrainTestSplit<T>
Helpers & Utilities · AiDotNet.Preprocessing
Provides simple, standalone utility methods for splitting data into training, validation, and test sets.
For Beginners
Before training a machine learning model, you need to split your data:
- Training set: The data the model learns from (typically 70-80%)
- Test set: The data used to evaluate how well the model performs on unseen data (typically 20-30%)
- Validation set (optional): Data used to tune hyperparameters during training (typically 10-15%)
This class provides simple static methods to perform these splits without needing to configure a full data preprocessor.
Methods
| Method | Summary |
|---|---|
List<ValueTuple<Matrix<T>, Matrix<T>, Vector<T>, Vector<T>>> KFoldSplit(Matrix<T> X, Vector<T> y, int k, bool shuffle, int randomSeed) |
Splits data into k folds for cross-validation. |
ValueTuple<Matrix<T>, Matrix<T>, Matrix<T>, Vector<T>, Vector<T>, Vector<T>> SplitThreeWay(Matrix<T> X, Vector<T> y, double trainSize, double validationSize, bool shuffle, int randomSeed) |
Splits data into training, validation, and test sets. |
ValueTuple<Matrix<T>, Matrix<T>, Vector<T>, Vector<T>> Split(Matrix<T> X, Vector<T> y, double testSize, bool shuffle, int randomSeed) |
Splits data into training and test sets. |
ValueTuple<Matrix<T>, Matrix<T>> SplitX(Matrix<T> X, double testSize, bool shuffle, int randomSeed) |
Splits feature matrix only (without targets) into training and test sets. |