XRegressor
XRegressor provides transparent regression modeling with real-time explainability. Unlike black-box models, you get instant insights into how predictions are made for continuous target variables.
Overview
The XRegressor is xplainable's transparent regression model that uses the same feature-wise ensemble approach as XClassifier, but optimized for continuous target variables. It provides complete transparency while maintaining competitive performance with traditional regression models.
Important note on performance: XRegressor alone can be a weak predictor. To get strong predictive power, use the optimise_tail_sensitivity() method and/or fit an XEvolutionaryNetwork with Tighten and Evolve layers on top of the model.
Key Features
Inspect any prediction with one call. No surrogate fits, no Shapley sampling.
Update a single feature's tree in milliseconds — no full retrain required.
Each feature contributes through its own decision tree, providing granular insights.
Built-in prediction range constraints for realistic and bounded outputs.
Quick Start
Constructor Parameters
80.00010.0001False1101.0(-np.inf, np.inf)Methods
fit()
Fits the model to the training data. Internally normalises leaf weights using Ridge regression.
[]None'target'0.1Returns the fitted XRegressor instance.
predict()
Predicts the target value for each row. Predictions are clipped to prediction_range.
Returns a numpy array of predicted values.
evaluate()
Returns a dictionary of regression metrics.
The returned dictionary contains:
Explained VarianceMAE(Mean Absolute Error)MAPE(Mean Absolute Percentage Error)MSE(Mean Squared Error)RMSE(Root Mean Squared Error)RMSLE(Root Mean Squared Log Error,NaNif inputs are negative)R2 Score
explain()
Renders an interactive Altair chart showing feature importances and per-feature contribution profiles. Takes no data input -- it visualises the fitted model's internal profile.
Requires the altair package. Install with pip install xplainable[plotting].
optimise_tail_sensitivity()
Automatically optimises the tail_sensitivity parameter at a global level to minimise MAE.
Returns the optimised XRegressor instance.
update_feature_params()
Updates model parameters for a subset of features without retraining from scratch.
All parameter arguments are optional -- only the ones you pass will be updated.
Returns the updated XRegressor instance.
If you have already optimised the model with an XEvolutionaryNetwork, calling update_feature_params() will overwrite the optimised weights and the network will need to be re-run.
feature_importances (property)
Returns a dictionary mapping feature names to their normalised importance scores.
profile (property)
Returns the full model profile as a dictionary with keys 'base_value', 'numeric', and 'categorical'.
_transform()
Transforms input data into per-feature contribution scores.
Advanced Optimisation with XEvolutionaryNetwork
For stronger predictive performance, use the XEvolutionaryNetwork with Tighten and/or Evolve layers:
Tighten Layer
A leaf boosting algorithm that iteratively identifies the leaf node with the greatest potential impact and incrementally adjusts its weight.
Evolve Layer
A genetic algorithm that mutates leaf weights and selects the best mutations through natural selection and reproduction.
Partitioned Regression
For datasets with natural segments:
Hyperparameter Optimization
XParamOptimiser is designed for classification models. It uses StratifiedKFold and classification metrics internally. For regression, tune parameters manually or use optimise_tail_sensitivity() combined with XEvolutionaryNetwork.
Evaluation with sklearn
Or use the built-in evaluate() method:
Cloud Deployment
For deploying models to the Xplainable Cloud platform, see the REST API documentation.
Best Practices
Data Preparation
- Handle outliers carefully (they significantly impact regression)
- Set realistic prediction bounds using
prediction_range - Check for multicollinearity between features
- Remove ID columns by passing them via
id_columnsparameter infit()
Recommended Workflow
Troubleshooting
Poor prediction accuracy
Possible causes:
- Base model alone is weak (this is expected)
- Insufficient optimisation layers
Solutions:
- Always run
optimise_tail_sensitivity()after fitting - Add
TightenandEvolvelayers viaXEvolutionaryNetwork - Increase
max_depthor decreasemin_info_gain
Predictions outside expected range
Solutions:
- Set
prediction_rangeparameter in the constructor - Set
apply_range=Truewhen creatingXEvolutionaryNetwork
Model overfitting
Solutions:
- Increase
min_leaf_sizeparameter - Decrease
max_depth - Use a separate validation set to monitor
XEvolutionaryNetworkoptimisation - Add regularization through
min_info_gain
Next Steps
- Try binary classification for categorical targets
- Learn about preprocessing pipelines for data preparation
- REST API — Deploy and manage models via the API