ExtraTrees / Classifier Layer

Extremely Randomized Trees (ExtraTrees) Classifier: This class implements a meta estimator that fits a number of randomized decision trees (a.k.a. extra-trees) on various sub-samples of the dataset and uses averaging to improve the predictive accuracy and control over-fitting.

Mathematical form: where:

  • are randomized trees
  • M is number of trees
  • Random splits replace optimal splits

Key characteristics:

  • Extreme randomization
  • Faster than Random Forest
  • Lower variance
  • Parallel processing
  • Automatic feature selection

Common applications:

  • Large-scale classification
  • Rapid model development
  • Feature importance
  • Ensemble building
  • Online prediction

Computational notes:

  • Training: O(M * N * log(N)) or better
  • Memory: O(M * N)
  • Prediction: O(M * log(N))
  • Parallel capable

Outputs:

  1. Predicted Table: Input data with predictions
  2. Validation Results: Cross-validation metrics
  3. Test Metric: Test set performance
  4. ROC Curve Data: ROC analysis information
  5. Confusion Matrix: Classification breakdown
  6. Feature Importances: Variable importance scores
Table
0
0
Predicted Table
1
Validation Results
2
Test Metric
3
ROC Curve Data
4
Confusion Matrix
5
Feature Importances

SelectFeatures

[column, ...]

Feature columns for ExtraTrees Classification:

Data requirements:

  1. General format:

    • Numeric features
    • Encoded categoricals
    • No missing values
    • Clean data
  2. Preprocessing notes:

    • No scaling needed
    • Handles raw features
    • Robust to outliers
    • Automatic feature selection
  3. Feature quality:

    • Remove constants
    • Handle missing data
    • Check correlations
    • Consider feature counts

Note: If empty, uses all numeric columns except target

Target column for ExtraTrees Classification:

Requirements:

  1. Data format:

    • Categorical labels
    • At least two classes
    • No missing values
    • Clean encoding
  2. Class properties:

    • Handles imbalance via weights
    • Supports multi-class
    • No ordinal assumptions
    • Preserves class order
  3. Quality checks:

    • Verify encodings
    • Check distributions
    • Monitor rare classes
    • Validate categories

Params

oneof
DefaultParams

Default configuration for ExtraTrees Classifier:

  1. Ensemble settings:

    • N estimators: 100 trees
    • Bootstrap: False
    • Max samples: Auto
  2. Tree parameters:

    • Criterion: Gini
    • Max depth: None (unlimited)
    • Max features: Sqrt
    • Min samples split: 2
    • Min samples leaf: 1
  3. Randomization:

    • Random splits
    • Random features
    • No bootstrapping
  4. Regularization:

    • No explicit pruning
    • Default class weights
    • CCP alpha: 0.0

Best suited for:

  • Initial modeling
  • Fast training needs
  • Medium to large datasets
  • General classification

Fine-tuned configuration for ExtraTrees Classifier:

Parameter categories:

  1. Ensemble control
  2. Tree construction
  3. Randomization levels
  4. Regularization options

Note: Randomization parameters particularly important for ExtraTrees

Number of trees in forest:

Guidelines:

  • Small (50-100): Quick models
  • Medium (100-300): Standard use
  • Large (>300): Complex problems

Trade-offs:

  • More trees: Better stability
  • Parallel training possible
  • Diminishing returns
Gini

Split quality measures for extremely randomized trees:

Note: Applied after random split generation

Gini ~

Gini impurity criterion:

Formula:

Properties:

  • Range: [0, 1-1/K]
  • Fast computation
  • Default choice
  • Works with random splits
Entropy ~

Information gain criterion:

Formula:

Properties:

  • Range: [0, log(K)]
  • More granular
  • Slower computation
  • Information theoretic
Logloss ~

Logarithmic loss criterion:

Formula:

Properties:

  • Probability focused
  • Sensitive to uncertainties
  • Good for probabilities
  • Penalizes mistakes heavily

The maximum depth of the tree. If None, then nodes are expanded until all leaves are pure or until all leaves contain less than min_samples_split samples.

Values:

  • 0: Unlimited (grow until pure)
  • >0: Explicit depth limit

Controls complexity and memory

The minimum number of samples required to split an internal node:

  • Constraint: Nodes with < samples won't split
  • Higher values: More conservative trees
  • Prevents excessive randomization

The minimum number of samples required to be at a leaf node:

  • Ensures prediction stability
  • Controls overfitting
  • Affects tree depth

The minimum weighted fraction of the sum total of weights (of all the input samples) required to be at a leaf node:

  • Range: [0.0, 0.5]
  • Used with sample weights
  • Alternative size control
Auto

Feature subset size for random split generation:

Note: Critical for ExtraTrees randomization

Auto ~

Use all features:

Formula:

Properties:

  • Maximum information
  • Slower training
  • Less randomization
  • Good for few features
Sqrt ~

Square root of features:

Formula:

Properties:

  • Standard choice
  • Good default
  • Balanced speed
  • Common in practice
Log2 ~

Logarithmic scaling:

Formula:

Properties:

  • More aggressive reduction
  • Fastest training
  • Maximum randomization
  • Good for many features
Custom ~

User-specified count:

Properties:

  • Full control
  • Problem-specific
  • Manual optimization
  • Research purposes

Custom feature count:

  • Active when max_features=Custom
  • Must be ≥ 1 and ≤ total features

Maximum leaf count:

  • 0: Unlimited leaves
  • >0: Best-first growth with limit

Alternative to max_depth

Minimum impurity decrease:

  • Controls split quality
  • Useful with random splits
  • Pre-pruning mechanism
false

Whether bootstrap samples are used when building trees.

  • False: the whole dataset is used to build each tree
  • True: Additional randomization

Affects OOB score availability

false

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

  • Requires bootstrap=True
  • Provides validation estimate

Random seed control:

Affects:

  • Split generation
  • Feature selection
  • Bootstrap sampling
  • Set for reproducibility
false

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 forest. Useful for optimization.

None

Class weighting schemes for ExtraTrees:

Note: Affects all trees in ensemble

None ~

Equal class weights:

Properties:

  • No bias adjustment
  • Natural distributions
  • Default behavior
  • Fast computation
Balanced ~

Inverse frequency weights:

Formula:

Properties:

  • Handles imbalance
  • Adjusts importance
  • Fair to minorities
  • Class-sensitive

Cost-complexity pruning:

  • Post-pruning parameter
  • Larger values: More pruning
  • Controls tree complexity

The fraction of samples to draw from X to train each base estimator:

  • Range: [0.0, 1.0]
  • 0.0: Auto (use all)
  • Used with bootstrap=True

Hyperparameter optimization for ExtraTrees Classifier:

Search dimensions:

  1. Ensemble parameters:

    • Number of trees
    • Sampling strategy
    • Feature selection
  2. Tree construction:

    • Split criteria
    • Tree depth
    • Node constraints
  3. Randomization:

    • Bootstrap options
    • Feature subsets
    • Sample fractions

Computational impact:

  • Time: O(n_params * n_trees * N * log(N))
  • Memory: O(n_params * n_trees)
  • Parallel training possible

Best practices:

  • Start with randomization levels
  • Then tune tree parameters
  • Finally adjust ensemble size

NEstimators

[u32, ...]
100

Number of trees to evaluate:

Common ranges:

  1. Quick: [50, 100]
  2. Standard: [100, 200, 300]
  3. Extensive: [200, 400, 600]

Note: More trees increase stability

Criterion

[enum, ...]
Gini

Split quality measures for extremely randomized trees:

Note: Applied after random split generation

Gini ~

Gini impurity criterion:

Formula:

Properties:

  • Range: [0, 1-1/K]
  • Fast computation
  • Default choice
  • Works with random splits
Entropy ~

Information gain criterion:

Formula:

Properties:

  • Range: [0, log(K)]
  • More granular
  • Slower computation
  • Information theoretic
Logloss ~

Logarithmic loss criterion:

Formula:

Properties:

  • Probability focused
  • Sensitive to uncertainties
  • Good for probabilities
  • Penalizes mistakes heavily

MaxDepth

[u32, ...]
0

Tree depth limits to try:

Ranges:

  1. Shallow: [5, 10, 15]
  2. Medium: [10, 20, 30]
  3. Deep/None: [0, 20, 40]

MinSamplesSplit

[u32, ...]
2

Minimum split samples to try:

Common ranges:

  1. Fine: [2, 5, 10]
  2. Medium: [5, 10, 20]
  3. Coarse: [10, 20, 50]

MinSamplesLeaf

[u32, ...]
1

Minimum leaf samples to evaluate:

Ranges:

  1. Fine: [1, 2, 4]
  2. Medium: [4, 8, 16]
  3. Coarse: [10, 20, 30]

Minimum weighted fraction to try:

Ranges:

  1. Light: [0.0, 0.1]
  2. Medium: [0.0, 0.1, 0.2]
  3. Heavy: [0.1, 0.2, 0.3]

MaxFeatures

[enum, ...]
Auto

Feature subset size for random split generation:

Note: Critical for ExtraTrees randomization

Auto ~

Use all features:

Formula:

Properties:

  • Maximum information
  • Slower training
  • Less randomization
  • Good for few features
Sqrt ~

Square root of features:

Formula:

Properties:

  • Standard choice
  • Good default
  • Balanced speed
  • Common in practice
Log2 ~

Logarithmic scaling:

Formula:

Properties:

  • More aggressive reduction
  • Fastest training
  • Maximum randomization
  • Good for many features
Custom ~

User-specified count:

Properties:

  • Full control
  • Problem-specific
  • Manual optimization
  • Research purposes

MaxFeaturesF

[u32, ...]
1

Custom feature counts to try:

Only used with max_features=Custom Typical: [2, 4, 8, 16] or powers of 2

MaxLeafNodes

[u32, ...]
0

Maximum leaf node counts:

Ranges:

  1. Limited: [10, 20, 50]
  2. Medium: [50, 100, 200]
  3. Unlimited: Include [0]

Impurity decrease thresholds:

Ranges:

  1. Fine: [0.0, 0.0001, 0.001]
  2. Medium: [0.0, 0.001, 0.01]
  3. Coarse: [0.01, 0.05, 0.1]

Bootstrap

[bool, ...]
false

Bootstrap strategies:

Options:

  • [false]: Standard ExtraTrees
  • [true]: Additional randomization
  • [false, true]: Compare both

OobScore

[bool, ...]
false

OOB scoring options:

Options:

  • [false]: No OOB
  • [true]: Use OOB if possible Note: Requires bootstrap=True

WarmStart

[bool, ...]
false

Warm start options:

Options:

  • [false]: Fresh forests
  • [true]: Incremental building
  • [false, true]: Compare both

ClassWeight

[enum, ...]
None

Class weighting schemes for ExtraTrees:

Note: Affects all trees in ensemble

None ~

Equal class weights:

Properties:

  • No bias adjustment
  • Natural distributions
  • Default behavior
  • Fast computation
Balanced ~

Inverse frequency weights:

Formula:

Properties:

  • Handles imbalance
  • Adjusts importance
  • Fair to minorities
  • Class-sensitive

Random seed for reproducibility:

Controls:

  • Split generation
  • Feature selection
  • Cross-validation

CcpAlpha

[f64, ...]
0

Cost-complexity pruning alphas:

Ranges:

  1. Light: [0.0, 0.001, 0.01]
  2. Medium: [0.0, 0.01, 0.05]
  3. Heavy: [0.05, 0.1, 0.2]

MaxSamples

[f64, ...]
0

Sample size fractions:

Ranges:

  1. Small: [0.5, 0.7]
  2. Medium: [0.7, 0.8, 0.9]
  3. Large: [0.9, 1.0] Note: Used with bootstrap=True
Accuracy

Performance evaluation metrics for classification:

Purpose:

  • Model evaluation
  • Ensemble selection
  • Early stopping
  • Performance tracking

Selection criteria:

  • Problem objectives
  • Class distribution
  • Ensemble size
  • Computation resources
Default ~

Uses ensemble's built-in scoring:

Properties:

  • Weighted accuracy metric
  • Ensemble-aware scoring
  • Fast computation
  • Boosting-compatible

Best for:

  • Standard problems
  • Quick evaluation
  • Initial testing
  • Performance tracking
Accuracy ~

Standard classification accuracy:

Formula:

Properties:

  • Range: [0, 1]
  • Ensemble consensus
  • Intuitive metric
  • Equal error weights

Best for:

  • Balanced datasets
  • Equal error costs
  • Simple evaluation
  • Quick benchmarking
BalancedAccuracy ~

Class-normalized accuracy score:

Formula:

Properties:

  • Range: [0, 1]
  • Class-weighted
  • Imbalance-robust
  • Fair evaluation

Best for:

  • Imbalanced data
  • Varied class sizes
  • Minority focus
  • Fair assessment
LogLoss ~

Logarithmic loss (Cross-entropy):

Formula:

Properties:

  • Range: [0, ∞)
  • Probability-sensitive
  • Boosting-optimal
  • Confidence-aware

Best for:

  • Probability estimation
  • Boosting optimization
  • Risk assessment
  • Model calibration
RocAuc ~

Area Under ROC Curve:

Properties:

  • Range: [0, 1]
  • Ranking quality
  • Threshold-invariant
  • Ensemble-appropriate

Best for:

  • Binary problems
  • Ranking tasks
  • Score calibration
  • Model comparison

Note: Extended to multi-class via averaging

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