Skip to main content

xeries

CI PyPI version Python versions DOI License: MIT

Time Series eXplainability (XAI) for Forecasting

A comprehensive Python library for explainability and interpretability in multi-time series forecasting. xeries provides multiple explanation methods—including conditional permutation importance, SHAP, feature dropping, and causal analysis—with a unified API and interactive dashboard for understanding forecast decisions.

Why xeries?

Explaining and interpreting multi-time series forecasts is challenging:

  1. Standard methods fail on series-dependent features: Permutation importance and SHAP can create invalid data by pairing a lag from one series with a target from another.

  2. No unified explainability framework: Most libraries offer a single method (e.g., SHAP only) with limited support for time-series-specific analysis.

  3. Lack of temporal and comparative insights: Understanding performance across time windows, detecting significance, and comparing methods are difficult without custom tools.

xeries addresses these gaps with:

  • Conditional explanations that respect data structure
  • A focused CPI workflow for current production use
  • A roadmap for future explanation methods
  • A simple API for current cs-PFI workflows

Features

📊 Current Capability

  • Conditional Permutation Importance (cs-PFI): Permute features only within meaningful subgroups
    • Auto-discover groups using decision trees
    • Define custom groups based on domain knowledge

🛣️ Planned Roadmap

  • Conditional SHAP: Planned for a future release
  • SHAP-IQ: Planned for a future release
  • Feature Dropping: Planned for a future release
  • Causal Feature Importance: Planned for a future release

📡 Framework Adapters

  • scikit-learn: Direct support for sklearn estimators
  • skforecast: Seamless integration with multi-series forecasters (0.21+)
  • Custom Models: Wrap any forecaster with the BaseAdapter

📈 Visualization

Ready-to-use plotting utilities for feature importance and temporal analysis.

  • Publication-Ready Plots:
    • Feature importance bar charts
    • Heatmaps comparing multiple methods or conditions

Planned:

  • Interactive Dashboard: Unified interface for all explainability components
    • Method comparison visualizations
    • Interaction plots
  • HTML Report Generation: Auto-generate dashboards with Jinja2 templates
  • Jupyter Integration: Works seamlessly in notebooks

Installation

pip install xeries

With UV:

uv add xeries

For skforecast integration:

pip install xeries[skforecast]

Supported Explanation Methods

Method Status Use Case Notes
Conditional Permutation Importance Available Default choice; fast & interpretable Auto/manual grouping with tree-based or manual partitioning
Conditional SHAP Planned Local & global explanations Future release
SHAP-IQ Planned Feature interactions Future release
Feature Dropping Planned Complementary to importance Future release
Causal Feature Importance Planned Treatment effects Future release

Quick Start

Conditional Permutation Importance (Default)

from sklearn.ensemble import RandomForestRegressor
from skforecast.recursive import ForecasterRecursiveMultiSeries

from xeries import ConditionalPermutationImportance
from xeries.adapters.skforecast import from_skforecast

# Train your multi-series forecaster (skforecast 0.21+)
forecaster = ForecasterRecursiveMultiSeries(
    estimator=RandomForestRegressor(n_estimators=100, random_state=42),
    lags=24,
)
forecaster.fit(series=your_data)

# Same `series` as fit() is required for create_train_X_y (pass here or to get_training_data)
adapter = from_skforecast(forecaster, series=your_data)
X, y = adapter.get_training_data()

# Compute conditional importance (automatic tree-based cs-PFI)
explainer = ConditionalPermutationImportance(
    model=adapter,
    metric='mse',
    strategy='auto',
    n_repeats=5,
    random_state=42,
)

result = explainer.explain(X, y, features=['lag_1', 'lag_2', 'lag_3'])
print(result.to_dataframe())

Using Manual Groups

from xeries import ManualPartitioner, ConditionalPermutationImportance

# Domain groups: with skforecast 0.21+ wide data, series are ordinal-encoded in X.
# Map integers 0,1,... in the same order as forecaster.series_names_in_ (see adapter.forecaster).
mapping = {
    0: 'urban',
    1: 'suburban',
    2: 'urban',
}

partitioner = ManualPartitioner(mapping, series_col=adapter.get_series_column())

explainer = ConditionalPermutationImportance(
    model=adapter,
    metric='mse',
    strategy='manual',
    partitioner=partitioner,
)

result = explainer.explain(X, y)

Visualization

from xeries.visualization import plot_importance_bar, plot_importance_heatmap

# Bar chart
fig, ax = plot_importance_bar(result, max_features=10)

# Heatmap comparing multiple cs-PFI configurations
results = {'Auto': result_auto, 'Manual': result_manual}
fig, ax = plot_importance_heatmap(results)

Planned Methods

The following methods are planned for future releases and are not part of the current release:

  • Conditional SHAP
  • SHAP-IQ
  • Feature Dropping
  • Causal Feature Importance

Documentation

Full documentation is available at https://thec0dewriter.github.io/xeries

Development

Clone the repository:

git clone https://github.com/thec0dewriter/xeries.git
cd xeries

Install with development dependencies:

uv sync --dev

Run tests:

uv run pytest

Run linting:

uv run ruff check src tests
uv run ruff format src tests

Type checking:

uv run ty check src

Build documentation:

uv sync --group docs
uv run mkdocs serve

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Citation

If you use this library in your research, please cite:

@software{xeries,
  title = {xeries: Time Series eXplainability for Forecasting},
  author = {Kuti-Kreszács, Mátyás},
  year = {2026},
  doi = {10.5281/zenodo.19482748},
  publisher = {Zenodo},
  url = {https://github.com/thec0dewriter/xeries},
}

This project is informed by the following techniques and references:

Metadata

Release files for xeries 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for xeries 0.2.1
File Size Uploaded Provenance Actions
xeries-0.2.1.tar.gz 1.0 MB With provenance Details for xeries-0.2.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for xeries 0.2.1
File Interpreter ABI Platform Actions
xeries-0.2.1-py3-none-any.whl Python 3 none any Details for xeries-0.2.1-py3-none-any.whl

Total release size: 1.0 MB

Release files / xeries-0.2.1.tar.gz

Download URL xeries-0.2.1.tar.gz
Size 1.0 MB
Tags Source
SHA-256 checksum
How to use checksums
f0ec2cc2a9944f21a2532fdfdfebb0d0c8cf334e5557c0e74e8dd58829216727
BLAKE2b-256 checksum
How to use checksums
e677071021962d38b44bbd38722d08f4ede50ace48b49964709c18f7c5b10ce9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 28, 2026.

Transparency log

Release files / xeries-0.2.1-py3-none-any.whl

Download URL xeries-0.2.1-py3-none-any.whl
Size 28.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
cac7ce8fdcbd5df4fcb460843e0720a1ce2fd6a381748e6fbfe96def5afb499f
BLAKE2b-256 checksum
How to use checksums
d944e0ce2abf8ab184e4786485c3c8730f0fd0de05ce9c7f96e8fa703362d5f2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 28, 2026.

Transparency log

Security for xeries 0.2.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for xeries-0.2.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 28, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page