RandomForest / Regressor Layer

Random Forest Regression: Ensemble learning method. It is a meta estimator that fits a number of decision tree regressors on various sub-samples of the dataset and uses averaging to improve the predictive accuracy and control over-fitting. Trees in the forest use the best split strategy.

Mathematical formulation: where:

  • B is number of trees
  • Tᵦ are decision trees
  • x is input feature vector

Key characteristics:

  • Ensemble of decision trees
  • Bootstrap aggregation (bagging)
  • Random feature selection
  • Parallel training

Advantages:

  • Robust to overfitting
  • Handles non-linearity
  • Feature importance
  • Missing value tolerance

Common applications:

  • Financial forecasting
  • Environmental modeling
  • Risk assessment
  • Demand prediction
  • Sensor data analysis

Outputs:

  1. Predicted Table: Results with predictions
  2. Validation Results: Cross-validation metrics
  3. Test Metric: Hold-out performance
  4. Feature Importances: Variable rankings
Table
0
0
Predicted Table
1
Validation Results
2
Test Metric
3
Feature Importances

SelectFeatures

[column, ...]

Feature column selection for Random Forest:

Requirements:

  1. Data properties:

    • Numeric preferred
    • Categorical encoded
    • Missing values handled
    • Finite numbers
  2. Feature engineering:

    • Scaling optional
    • Interactions useful
    • Outliers tolerated
    • Correlations acceptable
  3. Best practices:

    • Remove redundant features
    • Create domain-specific features
    • Consider feature costs
    • Monitor importance scores
  4. Performance aspects:

    • Memory scales with features
    • Training time impact
    • Feature subset selection
    • Tree complexity growth

Preprocessing tips:

  • Encode categoricals (one-hot/label)
  • Handle missing (impute/flag)
  • Create interaction terms
  • Remove constant features

Note: If empty, uses all numeric columns except target

Target column for Random Forest Regression:

Requirements:

  1. Data type:

    • Numeric continuous
    • Finite values
    • No missing data
    • Real-valued output
  2. Statistical properties:

    • Any distribution acceptable
    • Outliers handled naturally
    • Non-linear patterns okay
    • Multi-modal supported
  3. Preprocessing needs:

    • No scaling required
    • Outliers can remain
    • Log-transform if skewed
    • Remove infinities
  4. Modeling considerations:

    • Value range impacts trees
    • Distribution affects splits
    • Extreme values influence depth
    • Noise level affects leaves

Best practices:

  • Check for missing values
  • Validate data range
  • Consider transformations
  • Document preprocessing

Note: Must be a single numeric column

Params

oneof
DefaultParams

Default Random Forest Regression Configuration:

Core settings:

  1. Ensemble structure:

    • 100 trees (n_estimators)
    • MSE split criterion
    • Bootstrap sampling
    • Sqrt max features
  2. Tree parameters:

    • Unlimited depth
    • Min samples split: 2
    • Min samples leaf: 1
    • No leaf weight constraints
  3. Randomization:

    • Bootstrap: true
    • OOB score: false
    • Random state: None
  4. Advanced settings:

    • No cost-complexity pruning
    • No max samples limit
    • Standard convergence

Suitable for:

  • Initial modeling
  • Medium-sized datasets
  • General regression tasks
  • Standard prediction needs

Expected behavior:

  • Balanced performance
  • Good generalization
  • Reasonable speed
  • Standard memory usage

Note: These defaults are based on extensive empirical testing and provide a good starting point for most regression problems. Adjust parameters based on specific needs using CustomParams or GridSearch.

Customizable Random Forest Regression Parameters:

Parameter categories:

  1. Ensemble control:

    • Number of trees
    • Bootstrap settings
    • Feature sampling
    • Sample weights
  2. Tree structure:

    • Depth limits
    • Node constraints
    • Split criteria
    • Leaf conditions
  3. Randomization:

    • Seed control
    • Sample ratios
    • OOB evaluation
    • Feature selection
  4. Performance tuning:

    • Memory usage
    • Computation speed
    • Model complexity
    • Pruning settings

Optimization goals:

  • Prediction accuracy
  • Training efficiency
  • Model robustness
  • Resource utilization

Number of trees in the forest:

Impact on model: where:

  • B is number of trees
  • ρ is tree correlation
  • σ² is tree variance

Guidelines:

  • Small (10-50): Fast training
  • Medium (100-300): Standard use
  • Large (300+): High accuracy

Trade-offs:

  • More trees = Better stability
  • Diminishing returns after threshold
  • Linear memory scaling
  • Parallel training capable
Mse

Split quality measurement criteria:

Selection impact:

  • Prediction accuracy
  • Training dynamics
  • Outlier sensitivity
  • Computational efficiency

Use cases:

  1. General regression: MSE
  2. Numeric stability: Friedman MSE
  3. Robust modeling: MAE
  4. Count prediction: Poisson

Trade-offs:

  • Accuracy vs speed
  • Robustness vs sensitivity
  • Bias vs variance
  • Memory vs precision
Mse ~

Mean Squared Error criterion:

Formula:

Properties:

  • Variance reduction
  • L2 loss minimization
  • Squared error scaling
  • Fast computation

Best for:

  • General regression
  • Normal distributions
  • Clean datasets
  • Default choice

Limitations:

  • Outlier sensitive
  • Scale dependent
  • Assumes normality
FriedManMse ~

Friedman's MSE criterion:

Formula: where w is node weight

Properties:

  • Weighted MSE
  • Improved stability
  • Better split selection
  • Node weight consideration

Best for:

  • Complex datasets
  • Deep trees
  • Weighted scenarios
  • Numeric precision needs

Advantages:

  • More stable splits
  • Better numeric behavior
  • Improved convergence
AbsoluteError ~

Mean Absolute Error criterion:

Formula:

Properties:

  • L1 loss minimization
  • Linear error scaling
  • Median-based splits
  • Outlier resistant

Best for:

  • Noisy datasets
  • Outlier presence
  • Skewed distributions
  • Robust predictions

Advantages:

  • Outlier robustness
  • Scale independence
  • Interpretable errors
Poisson ~

Poisson deviance criterion:

Formula:

Properties:

  • Count data modeling
  • Non-negative targets
  • Rate estimation
  • Log-linear splits

Best for:

  • Event frequencies
  • Rate predictions
  • Insurance claims
  • Occurrence modeling

Applications:

  • Risk analysis
  • Event prediction
  • Resource planning

Maximum tree depth limit:

Complexity control:

  • 0: Unlimited depth
  • log₂(n): Balanced trees
  • Small (3-7): Simple models
  • Large (8+): Complex patterns

Impact:

  • Memory usage: O(2^depth)
  • Training time
  • Model complexity
  • Overfitting risk

Guidelines:

  • Start shallow
  • Monitor validation
  • Consider sample size
  • Balance with min_samples

Minimum samples for node split:

Guidelines:

  • Small (2-5): Detailed splits
  • Medium (5-20): Balanced
  • Large (20+): Conservative

Effects:

  • Prevents overfitting
  • Controls tree size
  • Affects leaf purity
  • Smooths predictions

Scale with dataset:

  • Small data: Lower values
  • Large data: Higher values
  • Consider noise level

Minimum samples in leaf nodes:

Guidelines:

  • 1: Maximum detail
  • 2-10: Standard range
  • 10+: Smooth predictions

Benefits:

  • Prevents single-sample leaves
  • Reduces variance
  • Stabilizes predictions
  • Controls overfitting

Consider with:

  • Dataset size
  • Noise level
  • Prediction stability needs

Minimum weighted fraction at leaf:

Usage:

  • 0.0: No constraint
  • 0.1: 10% minimum weight
  • 0.5: Balanced trees

Applications:

  • Imbalanced data
  • Weighted samples
  • Cost-sensitive learning
  • Stratified modeling

Note: Requires sample_weights

Feature subset selection strategy for splits:

Tree building process:

  • At each split, sample features
  • Select best feature from subset
  • Increases tree diversity
  • Controls randomization

Trade-offs:

  • More features = Better local splits
  • Fewer features = More diverse trees
  • Speed vs randomization
  • Memory vs computation

Selection guide:

  • High dim data: Use sqrt/log2
  • Few features: Try all
  • Specific needs: Use custom
  • Unsure: Start with sqrt
All ~

Consider all features for splitting:

Properties:

  • Uses complete feature set
  • Optimal local splits
  • Slower computation
  • Less randomization

Best for:

  • Small feature sets
  • Important features unknown
  • Initial exploration
  • Baseline performance

Limitations:

  • Slower training
  • Less tree diversity
  • Higher correlation
Sqrt ~

Square root of total features:

Properties:

  • Standard RF default
  • Balanced exploration
  • Good tree diversity
  • Efficient computation

Best for:

  • General problems
  • High dimensional data
  • Classification tasks
  • Standard RF models

Advantages:

  • Proven effectiveness
  • Good tree diversity
  • Reasonable speed
Log2 ~

Logarithmic feature selection:

Properties:

  • More aggressive reduction
  • Highest tree diversity
  • Fastest computation
  • Most randomization

Best for:

  • Very high dimensions
  • Feature noise present
  • Speed requirements
  • Memory constraints

Trade-offs:

  • Speed vs accuracy
  • Diversity vs optimality
  • Memory efficiency
Custom ~

User-specified feature count:

Properties:

  • Flexible control
  • Manual optimization
  • Domain knowledge use
  • Tunable parameter

Best for:

  • Specific requirements
  • Known feature counts
  • Performance tuning
  • Research purposes

Usage:

  • Set via max_features_f
  • Validate carefully
  • Consider computation
  • Monitor performance

Custom value of max features. Only used when max_features is custom.

Maximum leaf node limit:

Tree size control:

  • 0: Unlimited leaves
  • log₂(n): Balanced trees
  • n/10: Conservative size

Properties:

  • Controls tree complexity
  • Alternative to max_depth
  • Memory efficient
  • Best-first growth

Usage scenarios:

  • Memory constraints
  • Speed requirements
  • Size control needs
  • Model simplification

Minimum impurity decrease for split:

Usage:

  • 0.0: All valid splits
  • Small (1e-5 to 1e-3): Fine control
  • Large (> 1e-2): Aggressive pruning

Benefits:

  • Prevents weak splits
  • Reduces complexity
  • Improves efficiency
  • Natural pruning
true

Whether bootstrap samples are used when building trees.

When True:

  • Sample with replacement
  • Enables OOB estimation
  • Reduces variance

When False:

  • Use all samples
  • No sample duplication
  • Lower bias
  • No OOB scores

Trade-offs:

  • Bias vs variance
  • Training stability
  • Model diversity
  • Evaluation options
false

Whether to use out-of-bag samples to estimate the generalization sxore.

Controls both the randomness of the bootstrapping of the samples used when building trees (if bootstrap=True) and the sampling of the features to consider when looking for the best split at each node (if max_features < n_features).

Controls randomization in:

  • Bootstrap sampling
  • Feature selection
  • Split selection
  • Tree building

Usage patterns:

  • 0: System random source
  • Fixed value: Reproducible results
  • None: Non-deterministic

Important for:

  • Reproducibility
  • Debugging
  • Cross-validation
  • Research studies
true

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.

When True:

  • Keep existing trees
  • Add more estimators
  • Incremental training
  • Continue fitting

Applications:

  • Online learning
  • Model updating
  • Iterative fitting
  • Performance tuning

Considerations:

  • Memory usage
  • Training history
  • Parameter consistency
  • State management

Cost-Complexity Pruning alpha:

Pruning criterion: where:

  • R(T) is tree error
  • |T| is leaf count
  • α is complexity parameter

Values:

  • 0.0: No pruning
  • Small (1e-4 to 1e-2): Light pruning
  • Large (> 1e-2): Heavy pruning

Benefits:

  • Reduces overfitting
  • Optimizes size
  • Improves generalization
  • Controls complexity

If bootstrap is True, the fraction of samples to draw from X to train each base estimator.

Settings:

  • 0.0: Auto (n_samples)
  • < 1.0: Fraction of samples
  • 1.0: Full bootstrap

Impact:

  • Tree diversity
  • Training speed
  • Memory usage
  • Model variance

Note: Only used when bootstrap=True

Random Forest hyperparameter optimization:

Search space organization:

  1. Ensemble parameters:

    • Number of trees
    • Bootstrap settings
    • Sample strategies
    • Feature selection
  2. Tree structure:

    • Depth control
    • Node constraints
    • Splitting rules
    • Leaf settings
  3. Regularization:

    • Complexity pruning
    • Impurity thresholds
    • Sample constraints
    • Size limits

Best practices:

  • Start coarse, refine later
  • Consider correlations
  • Monitor resource usage
  • Use domain knowledge

NEstimators

[u32, ...]
100

Number of trees search space:

Search strategies:

  1. Logarithmic scale:

    • [10, 50, 100, 200, 500]
    • Broad exploration
    • Resource efficient
  2. Fine-tuning:

    • [80, 100, 120, 150]
    • Around optimal value
    • Precision focus
  3. Large-scale:

    • [200, 500, 1000]
    • High accuracy needs
    • Resource intensive

Consider:

  • Training time
  • Memory limits
  • Accuracy needs
  • Diminishing returns

Criterion

[enum, ...]
Mse

Split quality measurement criteria:

Selection impact:

  • Prediction accuracy
  • Training dynamics
  • Outlier sensitivity
  • Computational efficiency

Use cases:

  1. General regression: MSE
  2. Numeric stability: Friedman MSE
  3. Robust modeling: MAE
  4. Count prediction: Poisson

Trade-offs:

  • Accuracy vs speed
  • Robustness vs sensitivity
  • Bias vs variance
  • Memory vs precision
Mse ~

Mean Squared Error criterion:

Formula:

Properties:

  • Variance reduction
  • L2 loss minimization
  • Squared error scaling
  • Fast computation

Best for:

  • General regression
  • Normal distributions
  • Clean datasets
  • Default choice

Limitations:

  • Outlier sensitive
  • Scale dependent
  • Assumes normality
FriedManMse ~

Friedman's MSE criterion:

Formula: where w is node weight

Properties:

  • Weighted MSE
  • Improved stability
  • Better split selection
  • Node weight consideration

Best for:

  • Complex datasets
  • Deep trees
  • Weighted scenarios
  • Numeric precision needs

Advantages:

  • More stable splits
  • Better numeric behavior
  • Improved convergence
AbsoluteError ~

Mean Absolute Error criterion:

Formula:

Properties:

  • L1 loss minimization
  • Linear error scaling
  • Median-based splits
  • Outlier resistant

Best for:

  • Noisy datasets
  • Outlier presence
  • Skewed distributions
  • Robust predictions

Advantages:

  • Outlier robustness
  • Scale independence
  • Interpretable errors
Poisson ~

Poisson deviance criterion:

Formula:

Properties:

  • Count data modeling
  • Non-negative targets
  • Rate estimation
  • Log-linear splits

Best for:

  • Event frequencies
  • Rate predictions
  • Insurance claims
  • Occurrence modeling

Applications:

  • Risk analysis
  • Event prediction
  • Resource planning

MaxDepth

[u32, ...]
0

Tree depth search space:

Search patterns:

  1. Basic range:

    • [5, 10, 15, None]
    • Standard problems
    • Balanced approach
  2. Shallow trees:

    • [3, 5, 7, 9]
    • Simple patterns
    • Fast training
  3. Deep trees:

    • [10, 15, 20, None]
    • Complex patterns
    • Large datasets

Monitor:

  • Overfitting risk
  • Memory usage
  • Training time
  • Model complexity

MinSamplesSplit

[u32, ...]
2

Minimum split samples search:

Search ranges:

  1. Fine-grained:

    • [2, 5, 10]
    • Detailed splits
    • Small datasets
  2. Standard:

    • [10, 20, 50]
    • Medium datasets
    • Balanced control
  3. Conservative:

    • [50, 100, 200]
    • Large datasets
    • Noise control

Scale with:

  • Dataset size
  • Noise level
  • Model stability
  • Memory constraints

MinSamplesLeaf

[u32, ...]
1

Minimum leaf samples search:

Search spaces:

  1. Detailed:

    • [1, 2, 4]
    • Fine patterns
    • Clean data
  2. Standard:

    • [5, 10, 20]
    • Normal noise
    • Stable predictions
  3. Robust:

    • [20, 50, 100]
    • High noise
    • Smooth predictions

Consider with:

  • min_samples_split
  • Data noise level
  • Prediction stability
  • Sample size

Leaf weight fraction search:

Search ranges:

  1. No constraint:

    • [0.0]
    • Default behavior
    • Unweighted cases
  2. Light weighting:

    • [0.0, 0.1, 0.2]
    • Mild balancing
    • Gentle constraint
  3. Heavy weighting:

    • [0.2, 0.3, 0.4]
    • Strong balancing
    • Strict constraint

Use with:

  • Sample weights
  • Class imbalance
  • Cost sensitivity
  • Data distribution

MaxFeatures

[enum, ...]
All

Feature subset selection strategy for splits:

Tree building process:

  • At each split, sample features
  • Select best feature from subset
  • Increases tree diversity
  • Controls randomization

Trade-offs:

  • More features = Better local splits
  • Fewer features = More diverse trees
  • Speed vs randomization
  • Memory vs computation

Selection guide:

  • High dim data: Use sqrt/log2
  • Few features: Try all
  • Specific needs: Use custom
  • Unsure: Start with sqrt
All ~

Consider all features for splitting:

Properties:

  • Uses complete feature set
  • Optimal local splits
  • Slower computation
  • Less randomization

Best for:

  • Small feature sets
  • Important features unknown
  • Initial exploration
  • Baseline performance

Limitations:

  • Slower training
  • Less tree diversity
  • Higher correlation
Sqrt ~

Square root of total features:

Properties:

  • Standard RF default
  • Balanced exploration
  • Good tree diversity
  • Efficient computation

Best for:

  • General problems
  • High dimensional data
  • Classification tasks
  • Standard RF models

Advantages:

  • Proven effectiveness
  • Good tree diversity
  • Reasonable speed
Log2 ~

Logarithmic feature selection:

Properties:

  • More aggressive reduction
  • Highest tree diversity
  • Fastest computation
  • Most randomization

Best for:

  • Very high dimensions
  • Feature noise present
  • Speed requirements
  • Memory constraints

Trade-offs:

  • Speed vs accuracy
  • Diversity vs optimality
  • Memory efficiency
Custom ~

User-specified feature count:

Properties:

  • Flexible control
  • Manual optimization
  • Domain knowledge use
  • Tunable parameter

Best for:

  • Specific requirements
  • Known feature counts
  • Performance tuning
  • Research purposes

Usage:

  • Set via max_features_f
  • Validate carefully
  • Consider computation
  • Monitor performance

MaxFeaturesF

[u32, ...]
1

Custom feature count search:

Search patterns:

  1. Conservative:

    • [n_features/3]
    • Safe selection
    • Fast training
  2. Standard:

    • [n_features/2]
    • Balanced choice
    • Medium range
  3. Aggressive:

    • [2n_features/3]
    • More features
    • Better splits

Note: Used only with MaxFeatures = Custom

MaxLeafNodes

[u32, ...]
0

Maximum leaf nodes search:

Search spaces:

  1. Unlimited: [0]

    • No restriction
    • Full growth
  2. Controlled:

    • [10, 50, 100]
    • Size limiting
    • Memory efficient
  3. Large-scale:

    • [100, 500, 1000]
    • Complex trees
    • Big datasets

Balance with:

  • max_depth
  • Memory limits
  • Model complexity
  • Training speed

Impurity decrease threshold search:

Search ranges:

  1. No pruning: [0.0]

    • All splits allowed
    • Maximum detail
  2. Light pruning:

    • [1e-5, 1e-4, 1e-3]
    • Noise reduction
    • Gentle control
  3. Heavy pruning:

    • [1e-3, 1e-2, 1e-1]
    • Strong control
    • Significant reduction

Impact:

  • Tree complexity
  • Training speed
  • Model size
  • Generalization

Bootstrap

[bool, ...]
true

Bootstrap sampling evaluation:

Options:

  1. Standard: [true]

    • With replacement
    • OOB available
  2. Alternative: [false]

    • Full samples
    • Lower variance
  3. Compare: [true, false]

    • Complete study
    • Method impact

Consider:

  • Dataset size
  • Model stability
  • OOB estimation needs
  • Training dynamics

OobScore

[bool, ...]
false

Out-of-bag scoring options:

Choices:

  1. Disabled: [false]

    • No OOB estimate
    • Faster training
  2. Enabled: [true]

    • With estimation
    • Extra validation
  3. Compare: [true, false]

    • Full evaluation
    • Cost-benefit study

Requirements:

  • bootstrap = true
  • Sufficient samples
  • Memory overhead
  • Computation cost

WarmStart

[bool, ...]
true

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:

  1. Enable: [true]

    • Reuse trees
    • Incremental fits
  2. Disable: [false]

    • Fresh starts
    • Independent fits
  3. Compare: [true, false]

    • Method study
    • Performance impact

Use cases:

  • Online learning
  • Parameter tuning
  • Memory efficiency
  • Iterative training

CcpAlpha

[f64, ...]
0

Cost-complexity pruning search:

Search ranges:

  1. No pruning: [0.0]

    • Full trees
    • Maximum detail
  2. Light pruning:

    • [0.001, 0.01, 0.1]
    • Size optimization
    • Gentle reduction
  3. Heavy pruning:

    • [0.1, 0.2, 0.3]
    • Strong reduction
    • Simple trees

Monitor:

  • Tree complexity
  • Performance impact
  • Model size
  • Generalization

MaxSamples

[f64, ...]
0

Bootstrap sample size search:

Search spaces:

  1. Default: [0.0]

    • Auto selection
    • Full bootstrapping
  2. Reduced:

    • [0.5, 0.7, 0.9]
    • Faster training
    • Memory efficient
  3. Fine-tuning:

    • [0.8, 0.9, 1.0]
    • Performance study
    • Optimal size

Consider:

  • Dataset size
  • Memory limits
  • Training speed
  • Model diversity

Random seed control:

Usage:

  • 0: System random
  • Fixed: Reproducible
  • None: Random behavior

Important for:

  • Result stability
  • Cross-validation
  • Parameter tuning
  • Research studies
R2score

Regression model evaluation metrics:

Purpose:

  • Model performance evaluation
  • Error measurement
  • Quality assessment
  • Model comparison

Selection criteria:

  • Error distribution
  • Scale sensitivity
  • Domain requirements
  • Business objectives
Default ~

Model's native scoring method:

  • Typically R² score
  • Model-specific implementation
  • Standard evaluation
  • Quick assessment
R2score ~

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
ExplainedVariance ~

Explained variance score:

Formula:

Properties:

  • Range: (-∞, 1]
  • Accounts for bias
  • Variance focus
  • Similar to R²

Best for:

  • Variance analysis
  • Bias assessment
  • Model stability
MaxError ~

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
NegMeanAbsoluteError ~

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
NegMeanSquaredError ~

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
NegRootMeanSquaredError ~

Negative root mean squared error:

Formula:

Properties:

  • Original scale
  • Outlier sensitive
  • Interpretable units
  • Negated for optimization

Best for:

  • Standard reporting
  • Interpretable errors
  • Model comparison
NegMeanSquaredLogError ~

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
NegMedianAbsoluteError ~

Negative median absolute error:

Formula:

Properties:

  • Highly robust
  • Original scale
  • Outlier resistant
  • Negated for optimization

Best for:

  • Robust evaluation
  • Heavy-tailed errors
  • Outlier presence
NegMeanPoissonDeviance ~

Negative Poisson deviance:

Formula:

Properties:

  • For count data
  • Non-negative values
  • Poisson assumption
  • Negated for optimization

Best for:

  • Count prediction
  • Event frequency
  • Rate modeling
NegMeanGammaDeviance ~

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
NegMeanAbsolutePercentageError ~

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
D2AbsoluteErrorScore ~

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²
D2PinballScore ~

D² score with pinball loss:

Properties:

  • Quantile focus
  • Asymmetric errors
  • Risk assessment
  • Distribution modeling

Best for:

  • Quantile regression
  • Risk analysis
  • Asymmetric costs
  • Distribution tails
D2TweedieScore ~

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

oneof
DefaultSplit

Standard 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

Random seed for reproducible splits. Ensures:

  • Consistent train/test sets
  • Reproducible experiments
  • Comparable model evaluations

Same seed guarantees identical splits across runs.

true

Data 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
0.8

Proportion 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
false

Maintain 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

oneof
DefaultCv

Standard 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
3

Number 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

Number 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.

Random 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.

true

Whether 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

Number 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

Seed for reproducible stratified splits. Ensures:

  • Consistent fold assignments
  • Reproducible results
  • Comparable experiments
  • Systematic validation

Fixed seed guarantees identical stratified splits.

false

Data 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

Number 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.

Random seed for reproducible shuffling. Controls:

  • Split randomization
  • Sample selection
  • Result reproducibility

Important for:

  • Debugging
  • Comparative studies
  • Result verification
0.2

Proportion 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

Number 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

Seed for reproducible stratified sampling. Ensures:

  • Consistent class proportions
  • Reproducible splits
  • Comparable experiments

Critical for:

  • Benchmarking
  • Research studies
  • Quality assurance
0.2

Fraction 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 + 1th 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.

Number 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

Maximum 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

Number 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

u64
0

Number 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