DistributionPreservingSplitter<T>
Models & Types ยท AiDotNet.Preprocessing.DataPreparation.Splitting.Stratified
Stratified split for regression targets that preserves the target distribution.
Inheritance: DataSplitterBase<T> โ DistributionPreservingSplitter<T>
For Beginners
Stratification is usually for classification (preserving class counts). But what about regression where targets are continuous?
How It Works
Solution: We bin the continuous target into groups, then stratify by those bins. This ensures both train and test have similar target distributions.
Example: If house prices range from $100k-$1M, we might create 10 bins: $100k-$190k, $190k-$280k, etc. Then ensure each split has proportional samples from each bin.
When to Use:
- Regression problems with skewed target distributions
- When you want representative samples across the target range
- Prevents scenarios where all expensive houses end up in test
Constructors
| Constructor | Summary |
|---|---|
DistributionPreservingSplitter(double testSize, int nBins, bool shuffle, int randomSeed) |
Creates a new distribution-preserving splitter for regression. |
Properties
| Property | Summary |
|---|---|
bool RequiresLabels { get; } |
|
string Description { get; } |
Methods
| Method | Summary |
|---|---|
DataSplitResult<T> Split(Matrix<T> X, Vector<T> y) |