HistGradientBoosting / Regressor Layer
Histogram-based Gradient Boosting Regression: Fast, scalable ensemble learning.
Mathematical formulation: where:
- Fₘ is the model at iteration m
- ν is the learning rate
- hₘ is the weak learner
Key characteristics:
- Histogram-based splits
- Gradient-based optimization
- Memory efficient binning
- Fast training speed
Advantages:
- Excellent performance
- Handles large datasets
- Memory efficient
- Various loss functions
Best for:
- Large datasets (>10K samples)
- High-dimensional data
- Complex relationships
- Production environments
Outputs:
- Predicted Table: Results with predictions
- Validation Results: Cross-validation metrics
- Test Metric: Hold-out performance
- Feature Importances: Variable rankings
SelectFeatures
[column, ...]Target column for Histogram Gradient Boosting:
Requirements:
-
Data type:
- Numeric continuous
- No missing values
- Finite numbers
- Matches loss function
-
Loss-specific needs:
- SquaredError: Any range
- AbsoluteError: Any range
- Gamma: Strictly positive
- Poisson: Non-negative
- Quantile: Any range
-
Statistical properties:
- Any distribution supported
- Handles non-linearity
- Robust to outliers
- Multi-modal okay
-
Quality checks:
- Validate value ranges
- Check for infinities
- Verify loss compatibility
- Consider transformations
Best practices:
- Clean missing values
- Choose appropriate loss
- Log-transform if skewed
- Document preprocessing
Note: Must be a single numeric column
SelectTarget
columnTarget column for Histogram Gradient Boosting:
Requirements:
-
Data type:
- Numeric continuous
- No missing values
- Finite numbers
- Matches loss function
-
Loss-specific needs:
- SquaredError: Any range
- AbsoluteError: Any range
- Gamma: Strictly positive
- Poisson: Non-negative
- Quantile: Any range
-
Statistical properties:
- Any distribution supported
- Handles non-linearity
- Robust to outliers
- Multi-modal okay
-
Quality checks:
- Validate value ranges
- Check for infinities
- Verify loss compatibility
- Consider transformations
Best practices:
- Clean missing values
- Choose appropriate loss
- Log-transform if skewed
- Document preprocessing
Note: Must be a single numeric column
Params
oneofDefault Histogram Gradient Boosting configuration:
Core settings:
-
Training dynamics:
- Learning rate: 0.1
- Max iterations: 100
- Squared error loss
- Early stopping: auto
-
Tree structure:
- Max leaf nodes: 31
- Unlimited depth
- Min samples leaf: 20
- Max bins: 255
-
Regularization:
- L2 term: 0.0
- All features used
- No warm start
- Standard binning
-
Early stopping:
- Validation fraction: 0.1
- Patience: 10 iterations
- Tolerance: 1e-7
- Automatic monitoring
Optimal for:
- Large datasets (>10K samples)
- Initial modeling
- Standard regression tasks
- Memory-constrained environments
Expected behavior:
- Fast training
- Good generalization
- Memory efficiency
- Automatic optimization
Customizable Histogram Gradient Boosting parameters:
Parameter categories:
-
Optimization:
- Loss function
- Learning rate
- Iterations
- Early stopping
-
Tree architecture:
- Node counts
- Tree depth
- Leaf samples
- Histogram bins
-
Regularization:
- L2 penalty
- Feature fraction
- Validation split
- Stopping criteria
-
Performance tuning:
- Binning strategy
- Memory usage
- Training speed
- Model complexity
Loss
enumLoss functions for gradient boosting:
Optimization objective:
Key properties:
- Squared Error: L2 norm
- Absolute Error: L1 norm
- Gamma: Right-skewed data
- Poisson: Count data
- Quantile: Percentile estimation
Selection impact:
- Prediction behavior
- Outlier sensitivity
- Distribution assumptions
- Optimization dynamics
Half squared error loss:
Formula:
Properties:
- Mean estimation
- Symmetric errors
- Outlier sensitive
- Quick convergence
Best for:
- Normal distributions
- General regression
- Clean datasets
- Initial modeling
Absolute error loss:
Formula:
Properties:
- Median estimation
- Robust to outliers
- Linear penalties
- Stable gradients
Best for:
- Noisy data
- Outlier presence
- Robust predictions
- Median forecasting
Half gamma deviance:
Formula:
Properties:
- Log-link function
- Right-skewed data
- Positive responses
- Multiplicative errors
Best for:
- Insurance claims
- Financial returns
- Positive continuous
- Scale-dependent variance
Half Poisson deviance:
Formula:
Properties:
- Count data modeling
- Non-negative values
- Mean=variance
- Log-link function
Best for:
- Event counts
- Rate modeling
- Discrete outcomes
- Interval events
Quantile regression loss:
Formula:
Properties:
- Percentile estimation
- Asymmetric penalties
- Distribution-free
- Robust predictions
Best for:
- Risk assessment
- Extreme values
- Conditional quantiles
- Uncertainty bounds
Quantile
f64If loss is “quantile”, this parameter specifies which quantile to be estimated and must be between 0 and 1.
Parameter meaning:
- 0.5: Median (P50)
- 0.1: Lower decile (P10)
- 0.9: Upper decile (P90)
Common values:
- Central: 0.5
- Lower tail: [0.1, 0.25]
- Upper tail: [0.75, 0.9]
Applications:
- Risk assessment
- Prediction intervals
- Extreme values
- Distribution analysis
Note: Only used with Quantile loss
LearningRate
f64Gradient descent step size:
Formula: where ν is learning rate
Guidelines:
- Small (0.01-0.05): Precise
- Medium (0.1): Standard
- Large (0.3-0.5): Fast
Trade-offs:
- Smaller: Better accuracy
- Larger: Faster training
- Balance with iterations
- Monitor convergence
MaxIter
u32Maximum boosting iterations:
Iteration process: where M is max_iter
Guidelines:
- Small (50-100): Simple
- Medium (100-500): Standard
- Large (500+): Complex
Consider with:
- Learning rate
- Early stopping
- Dataset size
- Model complexity
MaxLeafNodes
u32Maximum leaf nodes per tree:
Tree capacity:
- 0: Unlimited leaves
- Powers of 2 minus 1: Balanced
- Other values: Custom structure
Common settings:
- Small (7-15): Simple trees
- Medium (31): Default
- Large (63-127): Complex
Impact:
- Model complexity
- Memory usage
- Training speed
- Prediction detail
MaxDepth
u32Maximum tree depth limit:
Depth control:
- 0: No limit
- log2(n): Balanced
- Fixed value: Controlled
Guidelines:
- Shallow (3-5): Fast, simple
- Medium (6-10): Balanced
- Deep (10+): Complex
Trade-offs:
- Deeper: More detail
- Shallower: Less overfitting
- Memory impact
- Training speed
Minimum samples per leaf:
Guidelines:
- Small data: 5-10
- Medium: 20 (default)
- Large data: 50-100
Benefits:
- Prevents overfitting
- Stabilizes trees
- Reduces variance
- Controls complexity
L2 regularization strength:
Penalty term:
Values:
- 0.0: No regularization
- 0.1-1.0: Moderate
- 1.0+: Strong
Effects:
- Reduces overfitting
- Smooths predictions
- Shrinks weights
- Improves stability
MaxFeatures
f64Feature fraction for splits:
Selection process:
Common values:
- 1.0: Use all features
- 0.7-0.9: Slight reduction
- 0.5-0.7: Significant reduction
Benefits:
- Reduces overfitting
- Increases randomization
- Speeds up training
- Memory efficient
MaxBins
u32The maximum number of bins to use for non-missing values. Before training, each feature of the input array X is binned into integer-valued bins, which allows for a much faster training stage.
Binning impact:
- Memory usage ∝ bins
- Training speed ∝ 1/bins
- Precision ∝ bins
Guidelines:
- 255: Maximum precision
- 100-200: Balanced
- 50-100: Memory efficient
Trade-offs:
- More bins: Better splits
- Fewer bins: Faster training
- Memory constraints
- Numerical precision
WarmStart
boolWhen set to True, reuse the solution of the previous call to fit and add more estimators to the ensemble, otherwise, just fit a whole new ensemble.
When True:
- Reuse existing trees
- Add more iterations
- Continue training
- Preserve learning
Applications:
- Online learning
- Model updating
- Iterative fitting
- Performance tuning
Trade-offs:
- Memory persistence
- Training flexibility
- Parameter consistency
- State management
EarlyStopping
boolValidation-based stopping:
Benefits:
- Prevents overfitting
- Optimizes iterations
- Saves computation
- Automatic tuning
Requirements:
- Validation data
- Patience setting
- Tolerance level
- Score monitoring
Early stopping validation size:
Data split:
Guidelines:
- Small data: 0.2
- Medium: 0.1 (default)
- Large data: 0.05
Considerations:
- Dataset size
- Validation stability
- Training efficiency
- Stopping reliability
Early stopping patience:
Stopping logic:
- Monitor n consecutive iterations
- Check score improvement > tol
- Stop if no improvement
Settings:
- Short (5): Quick stopping
- Medium (10): Default
- Long (20+): Patient
Impact:
- Training duration
- Convergence certainty
- Resource usage
- Model optimization
Tol
f64Early stopping tolerance:
Improvement threshold:
Typical values:
- Strict (1e-7): Default
- Medium (1e-5): Standard
- Loose (1e-3): Quick
Trade-offs:
- Smaller: More precise
- Larger: Faster stopping
- Balance with patience
- Consider noise level
RandomState
u64Pseudo-random number generator to control the subsampling in the binning process, and the train/validation data split if early stopping is enabled.
Controls randomization in:
- Feature selection
- Validation splits
- Histogram binning
- Tree building
Usage:
- 0: System random
- Fixed: Reproducible
- Different: Ensemble study
Important for:
- Reproducibility
- Debugging
- Research
- Model comparison
Histogram Gradient Boosting optimization:
Search categories:
-
Learning process:
- Loss functions
- Learning rates
- Iterations
- Early stopping
-
Tree structure:
- Node counts
- Tree depth
- Leaf constraints
- Binning strategy
-
Regularization:
- L2 penalty
- Feature fraction
- Sample controls
- Complexity limits
Best practices:
- Start with key parameters
- Consider interactions
- Monitor resources
- Use domain knowledge
Loss
[enum, ...]Loss functions for gradient boosting:
Optimization objective:
Key properties:
- Squared Error: L2 norm
- Absolute Error: L1 norm
- Gamma: Right-skewed data
- Poisson: Count data
- Quantile: Percentile estimation
Selection impact:
- Prediction behavior
- Outlier sensitivity
- Distribution assumptions
- Optimization dynamics
Half squared error loss:
Formula:
Properties:
- Mean estimation
- Symmetric errors
- Outlier sensitive
- Quick convergence
Best for:
- Normal distributions
- General regression
- Clean datasets
- Initial modeling
Absolute error loss:
Formula:
Properties:
- Median estimation
- Robust to outliers
- Linear penalties
- Stable gradients
Best for:
- Noisy data
- Outlier presence
- Robust predictions
- Median forecasting
Half gamma deviance:
Formula:
Properties:
- Log-link function
- Right-skewed data
- Positive responses
- Multiplicative errors
Best for:
- Insurance claims
- Financial returns
- Positive continuous
- Scale-dependent variance
Half Poisson deviance:
Formula:
Properties:
- Count data modeling
- Non-negative values
- Mean=variance
- Log-link function
Best for:
- Event counts
- Rate modeling
- Discrete outcomes
- Interval events
Quantile regression loss:
Formula:
Properties:
- Percentile estimation
- Asymmetric penalties
- Distribution-free
- Robust predictions
Best for:
- Risk assessment
- Extreme values
- Conditional quantiles
- Uncertainty bounds
Quantile
[f64, ...]Quantile level search space:
Search patterns:
-
Central tendency:
- [0.5]
- Median prediction
- Standard reference
-
Prediction intervals:
- [0.1, 0.5, 0.9]
- 80% interval
- Risk assessment
-
Fine-grained:
- [0.25, 0.5, 0.75]
- Quartile analysis
- Distribution study
Note: Only for quantile loss
LearningRate
[f64, ...]Learning rate search space:
Search strategies:
-
Logarithmic scale:
- [0.01, 0.1, 0.3]
- Wide exploration
- Standard range
-
Fine-tuning:
- [0.08, 0.1, 0.12]
- Around optimal
- Precise control
-
Combined with iterations:
- Smaller rate → more iterations
- Larger rate → fewer iterations
- Balance accuracy/speed
MaxIter
[u32, ...]Maximum iterations search:
Search ranges:
-
Standard scale:
- [50, 100, 200]
- Basic problems
- Quick exploration
-
Extended range:
- [100, 300, 500]
- Complex problems
- Higher accuracy
-
With early stopping:
- Set higher limits
- Let stopping decide
- Monitor convergence
MaxLeafNodes
[u32, ...]Leaf nodes search space:
Search patterns:
-
Binary tree levels:
- [15, 31, 63]
- Powers of 2 minus 1
- Balanced trees
-
Memory constrained:
- [7, 15, 31]
- Smaller trees
- Faster training
-
Complex patterns:
- [31, 63, 127]
- Detailed trees
- More capacity
MaxDepth
[u32, ...]Tree depth search space:
Search ranges:
-
Controlled depth:
- [3, 5, 7]
- Simple trees
- Fast prediction
-
Standard range:
- [6, 8, 10]
- Balanced complexity
- Medium datasets
-
Deep trees:
- [10, 15, 0]
- Complex patterns
- Large datasets
- 0 for unlimited
MinSamplesLeaf
[u32, ...]Minimum leaf samples search:
Search spaces:
-
Small datasets:
- [5, 10, 20]
- Detailed trees
- Fine patterns
-
Medium scale:
- [20, 50, 100]
- Balanced smoothing
- Standard choice
-
Large datasets:
- [100, 200, 500]
- Strong smoothing
- Stable predictions
L2Regularization
[f64, ...]L2 regularization search:
Search patterns:
-
Light regularization:
- [0.0, 0.01, 0.1]
- Gentle control
- Initial study
-
Standard range:
- [0.1, 1.0, 10.0]
- Log-scale search
- Common values
-
Strong regularization:
- [1.0, 10.0, 100.0]
- Heavy smoothing
- Overfitting control
MaxFeatures
[f64, ...]Feature fraction search:
Search spaces:
-
Minor reduction:
- [0.8, 0.9, 1.0]
- Gentle randomization
- Speed improvement
-
Moderate reduction:
- [0.6, 0.7, 0.8]
- Balance speed/accuracy
- Standard range
-
Significant reduction:
- [0.4, 0.5, 0.6]
- Strong randomization
- Fast training
MaxBins
[u32, ...]Histogram bins search:
Search ranges:
-
Memory efficient:
- [32, 64, 128]
- Fast training
- Low memory
-
Balanced:
- [128, 200, 255]
- Good precision
- Standard choice
-
High precision:
- [200, 225, 255]
- Best splits
- More memory
WarmStart
[bool, ...]When set to True, reuse the solution of the previous call to fit and add more estimators to the ensemble, otherwise, just fit a whole new ensemble.
Options:
-
Standard: [false]
- Fresh training
- Independent runs
-
Compare: [true, false]
- Study reuse impact
- Performance effect
Consider with:
- Training strategy
- Memory usage
- Iteration control
EarlyStopping
boolEarly stopping control:
When enabled:
- Monitors validation score
- Prevents overfitting
- Optimizes iterations
- Saves computation
Requirements:
- Validation data
- Patience setting
- Score monitoring
Validation split size:
Considerations:
- Dataset size impact
- Stopping reliability
- Training efficiency
- Validation stability
Guidelines:
- Small data: 0.2
- Standard: 0.1
- Large data: 0.05
Stopping patience:
Impact:
- Training duration
- Convergence check
- Resource usage
- Optimization level
Settings:
- Quick: 5 iterations
- Standard: 10 iterations
- Patient: 20+ iterations
Tol
f64Improvement tolerance:
Usage guide:
- Strict (1e-7): Default
- Medium (1e-5): Common
- Loose (1e-3): Quick
Trade-offs:
- Convergence precision
- Training duration
- Resource efficiency
RandomState
u64Random seed control:
Usage:
- 0: System random
- Fixed: Reproducible
- None: Random behavior
Important for:
- Result stability
- Cross-validation
- Research studies
RefitScore
enumRegression model evaluation metrics:
Purpose:
- Model performance evaluation
- Error measurement
- Quality assessment
- Model comparison
Selection criteria:
- Error distribution
- Scale sensitivity
- Domain requirements
- Business objectives
Model's native scoring method:
- Typically R² score
- Model-specific implementation
- Standard evaluation
- Quick assessment
Coefficient of determination (R²):
Formula:
Properties:
- Range: (-∞, 1]
- 1: Perfect prediction
- 0: Constant model
- Negative: Worse than mean
Best for:
- General performance
- Variance explanation
- Model comparison
- Standard reporting
Explained variance score:
Formula:
Properties:
- Range: (-∞, 1]
- Accounts for bias
- Variance focus
- Similar to R²
Best for:
- Variance analysis
- Bias assessment
- Model stability
Maximum absolute error:
Formula:
Properties:
- Worst case error
- Original scale
- Sensitive to outliers
- Upper error bound
Best for:
- Critical applications
- Error bounds
- Safety margins
- Risk assessment
Negative mean absolute error:
Formula:
Properties:
- Linear error scale
- Robust to outliers
- Original units
- Negated for optimization
Best for:
- Robust evaluation
- Interpretable errors
- Outlier presence
Negative mean squared error:
Formula:
Properties:
- Squared error scale
- Outlier sensitive
- Squared units
- Negated for optimization
Best for:
- Standard optimization
- Large error penalty
- Statistical analysis
Negative root mean squared error:
Formula:
Properties:
- Original scale
- Outlier sensitive
- Interpretable units
- Negated for optimization
Best for:
- Standard reporting
- Interpretable errors
- Model comparison
Negative mean squared logarithmic error:
Formula:
Properties:
- Relative error scale
- For positive values
- Sensitive to ratios
- Negated for optimization
Best for:
- Exponential growth
- Relative differences
- Positive predictions
Negative median absolute error:
Formula:
Properties:
- Highly robust
- Original scale
- Outlier resistant
- Negated for optimization
Best for:
- Robust evaluation
- Heavy-tailed errors
- Outlier presence
Negative Poisson deviance:
Formula:
Properties:
- For count data
- Non-negative values
- Poisson assumption
- Negated for optimization
Best for:
- Count prediction
- Event frequency
- Rate modeling
Negative Gamma deviance:
Formula:
Properties:
- For positive continuous data
- Constant CV assumption
- Relative errors
- Negated for optimization
Best for:
- Positive continuous data
- Multiplicative errors
- Financial modeling
Negative mean absolute percentage error:
Formula:
Properties:
- Percentage scale
- Scale independent
- For non-zero targets
- Negated for optimization
Best for:
- Relative performance
- Scale-free comparison
- Business metrics
D² score with absolute error:
Formula:
Properties:
- Range: (-∞, 1]
- Robust version of R²
- Linear error scale
- Outlier resistant
Best for:
- Robust evaluation
- Non-normal errors
- Alternative to R²
D² score with pinball loss:
Properties:
- Quantile focus
- Asymmetric errors
- Risk assessment
- Distribution modeling
Best for:
- Quantile regression
- Risk analysis
- Asymmetric costs
- Distribution tails
D² score with Tweedie deviance:
Properties:
- Compound Poisson-Gamma
- Flexible dispersion
- Mixed distributions
- Insurance modeling
Best for:
- Insurance claims
- Mixed continuous-discrete
- Compound distributions
- Specialized modeling
Split
oneofStandard train-test split configuration optimized for general classification tasks.
Configuration:
- Test size: 20% (0.2)
- Random seed: 98
- Shuffling: Enabled
- Stratification: Based on target distribution
Advantages:
- Preserves class distribution
- Provides reliable validation
- Suitable for most datasets
Best for:
- Medium to large datasets
- Independent observations
- Initial model evaluation
Splitting uses the ShuffleSplit strategy or StratifiedShuffleSplit strategy depending on the field stratified
. Note: If shuffle is false then stratified must be false.
Configurable train-test split parameters for specialized requirements. Allows fine-tuning of data division strategy for specific use cases or constraints.
Use cases:
- Time series data
- Grouped observations
- Specific train/test ratios
- Custom validation schemes
RandomState
u64Random seed for reproducible splits. Ensures:
- Consistent train/test sets
- Reproducible experiments
- Comparable model evaluations
Same seed guarantees identical splits across runs.
Shuffle
boolData shuffling before splitting. Effects:
- true: Randomizes order, better for i.i.d. data
- false: Maintains order, important for time series
When to disable:
- Time dependent data
- Sequential patterns
- Grouped observations
TrainSize
f64Proportion of data for training. Considerations:
- Larger (e.g., 0.8-0.9): Better model learning
- Smaller (e.g., 0.5-0.7): Better validation
Common splits:
- 0.8: Standard (80/20 split)
- 0.7: More validation emphasis
- 0.9: More training emphasis
Stratified
boolMaintain class distribution in splits. Important when:
- Classes are imbalanced
- Small classes present
- Representative splits needed
Requirements:
- Classification tasks only
- Cannot use with shuffle=false
- Sufficient samples per class
Cv
oneofStandard cross-validation configuration using stratified 3-fold splitting.
Configuration:
- Folds: 3
- Method: StratifiedKFold
- Stratification: Preserves class proportions
Advantages:
- Balanced evaluation
- Reasonable computation time
- Good for medium-sized datasets
Limitations:
- May be insufficient for small datasets
- Higher variance than larger fold counts
- May miss some data patterns
Configurable stratified k-fold cross-validation for specific validation requirements.
Features:
- Adjustable fold count with
NFolds
determining the number of splits. - Stratified sampling
- Preserved class distributions
Use cases:
- Small datasets (more folds)
- Large datasets (fewer folds)
- Detailed model evaluation
- Robust performance estimation
NFolds
u32Number of cross-validation folds. Guidelines:
- 3-5: Large datasets, faster training
- 5-10: Standard choice, good balance
- 10+: Small datasets, thorough evaluation
Trade-offs:
- More folds: Better evaluation, slower training
- Fewer folds: Faster training, higher variance
Must be at least 2.
K-fold cross-validation without stratification. Divides data into k consecutive folds for iterative validation.
Process:
- Splits data into k equal parts
- Each fold serves as validation once
- Remaining k-1 folds form training set
Use cases:
- Regression problems
- Large, balanced datasets
- When stratification unnecessary
- Continuous target variables
Limitations:
- May not preserve class distributions
- Less suitable for imbalanced data
- Can create biased splits with ordered data
NSplits
u32Number of folds for cross-validation. Selection guide: Recommended values:
- 5: Standard choice (default)
- 3: Large datasets/quick evaluation
- 10: Thorough evaluation/smaller datasets
Trade-offs:
- Higher values: More thorough, computationally expensive
- Lower values: Faster, potentially higher variance
Must be at least 2 for valid cross-validation.
RandomState
u64Random seed for fold generation when shuffling. Important for:
- Reproducible results
- Consistent fold assignments
- Benchmark comparisons
- Debugging and validation
Set specific value for reproducibility across runs.
Shuffle
boolWhether to shuffle data before splitting into folds. Effects:
- true: Randomized fold composition (recommended)
- false: Sequential splitting
Enable when:
- Data may have ordering
- Better fold independence needed
Disable for:
- Time series data
- Ordered observations
Stratified K-fold cross-validation maintaining class proportions across folds.
Key features:
- Preserves class distribution in each fold
- Handles imbalanced datasets
- Ensures representative splits
Best for:
- Classification problems
- Imbalanced class distributions
- When class proportions matter
Requirements:
- Classification tasks only
- Sufficient samples per class
- Categorical target variable
NSplits
u32Number of stratified folds. Guidelines: Typical values:
- 5: Standard for most cases
- 3: Quick evaluation/large datasets
- 10: Detailed evaluation/smaller datasets
Considerations:
- Must allow sufficient samples per class per fold
- Balance between stability and computation time
- Consider smallest class size when choosing
RandomState
u64Seed for reproducible stratified splits. Ensures:
- Consistent fold assignments
- Reproducible results
- Comparable experiments
- Systematic validation
Fixed seed guarantees identical stratified splits.
Shuffle
boolData shuffling before stratified splitting. Impact:
- true: Randomizes while maintaining stratification
- false: Maintains data order within strata
Use cases:
- true: Independent observations
- false: Grouped or sequential data
Class proportions maintained regardless of setting.
Random permutation cross-validator with independent sampling.
Characteristics:
- Random sampling for each split
- Independent train/test sets
- More flexible than K-fold
- Can have overlapping test sets
Advantages:
- Control over test size
- Fresh splits each iteration
- Good for large datasets
Limitations:
- Some samples might never be tested
- Others might be tested multiple times
- No guarantee of complete coverage
NSplits
u32Number of random splits to perform. Consider: Common values:
- 5: Standard evaluation
- 10: More thorough assessment
- 3: Quick estimates
Trade-offs:
- More splits: Better estimation, longer runtime
- Fewer splits: Faster, less stable estimates
Balance between computation and stability.
RandomState
u64Random seed for reproducible shuffling. Controls:
- Split randomization
- Sample selection
- Result reproducibility
Important for:
- Debugging
- Comparative studies
- Result verification
TestSize
f64Proportion of samples for test set. Guidelines: Common ratios:
- 0.2: Standard (80/20 split)
- 0.25: More validation emphasis
- 0.1: More training data
Considerations:
- Dataset size
- Model complexity
- Validation requirements
It must be between 0.0 and 1.0.
Stratified random permutation cross-validator combining shuffle-split with stratification.
Features:
- Maintains class proportions
- Random sampling within strata
- Independent splits
- Flexible test size
Ideal for:
- Imbalanced datasets
- Large-scale problems
- When class distributions matter
- Flexible validation schemes
NSplits
u32Number of stratified random splits. Guidelines: Recommended values:
- 5: Standard evaluation
- 10: Detailed analysis
- 3: Quick assessment
Consider:
- Sample size per class
- Computational resources
- Stability requirements
RandomState
u64Seed for reproducible stratified sampling. Ensures:
- Consistent class proportions
- Reproducible splits
- Comparable experiments
Critical for:
- Benchmarking
- Research studies
- Quality assurance
TestSize
f64Fraction of samples for stratified test set. Best practices: Common splits:
- 0.2: Balanced evaluation
- 0.3: More thorough testing
- 0.15: Preserve training size
Consider:
- Minority class size
- Overall dataset size
- Validation objectives
It must be between 0.0 and 1.0.
Time Series cross-validator. Provides train/test indices to split time series data samples that are observed at fixed time intervals, in train/test sets. It is a variation of k-fold which returns first k
folds as train set and the k + 1
th fold as test set. Note that unlike standard cross-validation methods, successive training sets are supersets of those that come before them. Also, it adds all surplus data to the first training partition, which is always used to train the model.
Key features:
- Maintains temporal dependence
- Expanding window approach
- Forward-chaining splits
- No future data leakage
Use cases:
- Sequential data
- Financial forecasting
- Temporal predictions
- Time-dependent patterns
Note: Training sets are supersets of previous iterations.
NSplits
u32Number of temporal splits. Considerations: Typical values:
- 5: Standard forward chaining
- 3: Limited historical data
- 10: Long time series
Impact:
- Affects training window growth
- Determines validation points
- Influences computational load
MaxTrainSize
u64Maximum size of training set. Should be strictly less than the number of samples. Applications:
- 0: Use all available past data
- >0: Rolling window of fixed size
Use cases:
- Limit historical relevance
- Control computational cost
- Handle concept drift
- Memory constraints
TestSize
u64Number of samples in each test set. When 0:
- Auto-calculated as n_samples/(n_splits+1)
- Ensures equal-sized test sets
Considerations:
- Forecast horizon
- Validation requirements
- Available future data
Gap
u64Number of samples to exclude from the end of each train set before the test set.Gap between train and test sets. Uses:
- Avoid data leakage
- Model forecast lag
- Buffer periods
Common scenarios:
- 0: Continuous prediction
- >0: Forward gap for realistic evaluation
- Match business forecasting needs