XEvolutionaryNetwork
XEvolutionaryNetwork is a layer-based optimization framework specifically designed for optimizing the leaf weights of XRegressor models. It chains together optimization layers (Tighten and Evolve) to iteratively improve model predictions.
Overview
XEvolutionaryNetwork takes a pre-trained XRegressor model and optimizes its leaf node weights through a series of configurable layers. It is inspired by deep learning frameworks but is applied over additive models for weight optimization.
The network can be stopped mid-training and resumed at any time. You can track remaining and completed layers using the future_layers and completed_layers attributes.
Key Benefits
- Layer-based architecture: Chain multiple optimization strategies together
- Flexible depth: No limit on the number of layers
- Pausable training: Stop and resume at any point
- Feature-level optimization: Optimize weights for a subset of features using the
subsetparameter
Architecture Overview
XEvolutionaryNetwork uses two types of optimization layers:
- Tighten: A leaf boosting algorithm that iteratively adjusts individual leaf weights to minimize error
- Evolve: A genetic algorithm that mutates and evolves leaf weight chromosomes across generations
Related Optimization Tools
These tools are separate from XEvolutionaryNetwork and serve different purposes:
- XParamOptimiser: Bayesian optimization for hyperparameter tuning of XClassifier models (not a layer in XEvolutionaryNetwork)
- Target: Finds model leaf nodes that achieve a target prediction value
- NLPOptimiser: Bayesian optimization for NLP preprocessing parameters
XEvolutionaryNetwork API
Constructor
Parameters:
model(XRegressor): The pre-trained XRegressor model to optimize.apply_range(bool): Whether to clip predictions to the model'sprediction_rangeduring optimization. Defaults toFalse.
Methods
Attributes
Optimization Layers
Tighten
A leaf boosting algorithm that iteratively identifies the single leaf node change that will have the greatest impact on the overall model score, then incrementally adjusts that leaf weight.
Parameters:
iterations(int): Number of optimization iterations. Defaults to100.learning_rate(float): Controls the step size of each weight adjustment. Between 0.001 and 1. Defaults to0.03.early_stopping(int, optional): Stop early if no improvement after n iterations. Defaults toNone.
Evolve
A genetic algorithm that generates mutations of the leaf weight chromosome, selects superior mutations, reproduces, and evolves toward better solutions.
Parameters:
mutations(int): Number of mutations to generate per generation. Defaults to100.generations(int): Number of generations to run. Defaults to50.max_generation_depth(int): Maximum depth of reproduction cycles within a generation. Defaults to10.max_severity(float): Maximum severity of a mutation (proportion of original value). Defaults to0.5.max_leaves(int): Maximum number of leaves to mutate in a single mutation. Defaults to20.early_stopping(int, optional): Stop early if no improvement after n generations. Defaults toNone.
Both layers optimize using either MAE or MSE (controlled by the metric attribute inherited from BaseLayer, defaulting to 'mae').
Basic Usage
Complete Workflow
Feature-Level Optimization
You can optimize weights for specific features only using the subset parameter:
Progressive Optimization
Build up optimization in stages, checking results between layers:
Using with Prediction Range
When your regression model has bounded predictions, use apply_range=True to clip predictions during optimization:
XParamOptimiser
XParamOptimiser is a separate Bayesian optimization tool for finding optimal hyperparameters for XClassifier models. It is not a layer in XEvolutionaryNetwork.
Constructor
Key Parameters:
metric(str): Optimization metric. Supported metrics include'roc-auc','accuracy','macro-f1','weighted-f1','positive-f1','negative-f1','brier-loss','log-loss', and various precision/recall variants. Defaults to'roc-auc'.n_trials(int): Number of Bayesian optimization trials. Defaults to30.n_folds(int): Number of cross-validation folds. Defaults to5.early_stopping(int): Stop if no improvement after n trials. Defaults to30.alpha(float): Sets the alpha of the model. Defaults to0.01.*_spaceparameters: Each is a list of[start, stop, step]values defining the search space. Pass a single value instead of a list to fix that parameter.
Usage
Target
The Target class finds model leaf nodes that achieve a specific target prediction value. It is not a layer in XEvolutionaryNetwork.
Constructor:
model: A fitted xplainable model.tolerance(float): Acceptable difference from the target value. Defaults to0.005.
run() method:
target(float): The target prediction value to achieve.iterations(int): Number of search iterations. Defaults to1000.locked(dict): Dictionary of feature names to values that should be fixed during search.
Returns a dictionary mapping feature names to their optimal leaf nodes.
NLPOptimiser
NLPOptimiser performs Bayesian optimization for NLP preprocessing parameters. It is not a layer in XEvolutionaryNetwork.
Best Practices
- Always train and evaluate the base model first before applying XEvolutionaryNetwork.
- Use
optimise_tail_sensitivity()on XRegressor before creating the evolutionary network. - Start with Tighten layers for initial improvement, then add Evolve layers for further refinement.
- Use early stopping to prevent overfitting and save computation time.
- Validate on held-out data -- the model is modified in place, so evaluate on test data after optimization.
- Be cautious with
update_feature_params()after optimization -- it overwrites the optimized weights.
Next Steps
- Explore rapid refitting for instant parameter updates on trained models
- Learn about partitioned models for segment-specific modeling
- Check out custom transformers for preprocessing pipelines