Metadata-Version: 2.5
Name: mimosa-illume
Version: 0.1.0
Summary: Post-hoc explanations for tabular data using interpretable meta-encoding
Project-URL: Repository, https://github.com/simonepiaggesi/illume
Project-URL: Paper, https://doi.org/10.1109/ICDM65498.2025.00074
Author-email: Simone Piaggesi <piaggesi.simone@gmail.com>
License: MIT License
        
        Copyright (c) 2025 Simone Piaggesi
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
Requires-Python: >=3.10
Requires-Dist: matplotlib>=3.5.3
Requires-Dist: more-itertools>=10.5.0
Requires-Dist: numpy>=1.23.4
Requires-Dist: pandas>=1.5.1
Requires-Dist: scikit-learn>=1.3.2
Requires-Dist: scipy>=1.10.1
Requires-Dist: tqdm>=4.64.1
Provides-Extra: dev
Requires-Dist: pytest>=8.0; extra == 'dev'
Provides-Extra: model
Requires-Dist: torch>=1.12.1; extra == 'model'
Requires-Dist: torchvision>=0.13.1; extra == 'model'
Provides-Extra: notebook
Requires-Dist: catboost>=1.2.7; extra == 'notebook'
Requires-Dist: ipykernel>=6.29.5; extra == 'notebook'
Requires-Dist: lightgbm>=4.5.0; extra == 'notebook'
Requires-Dist: torch>=1.12.1; extra == 'notebook'
Requires-Dist: torchvision>=0.13.1; extra == 'notebook'
Requires-Dist: xgboost>=1.5.1; extra == 'notebook'
Provides-Extra: paper
Requires-Dist: bitarray>=2.9.2; extra == 'paper'
Requires-Dist: catboost>=1.2.7; extra == 'paper'
Requires-Dist: category-encoders>=2.6.3; extra == 'paper'
Requires-Dist: deap>=1.4.1; extra == 'paper'
Requires-Dist: imbalanced-learn>=0.11.0; extra == 'paper'
Requires-Dist: ipython>=8.12.3; extra == 'paper'
Requires-Dist: joblib>=1.4.2; extra == 'paper'
Requires-Dist: lightgbm>=4.5.0; extra == 'paper'
Requires-Dist: lime>=0.2.0.1; extra == 'paper'
Requires-Dist: shap>=0.44.1; extra == 'paper'
Requires-Dist: sympy>=1.13.1; extra == 'paper'
Requires-Dist: torch>=1.12.1; extra == 'paper'
Requires-Dist: torchvision>=0.13.1; extra == 'paper'
Requires-Dist: xgboost>=1.5.1; extra == 'paper'
Description-Content-Type: text/markdown

# Explanations Go Linear: Post-hoc Explainability for Tabular Data with Interpretable Meta-Encoding

Code and data for running [ILLUME](https://arxiv.org/abs/2504.20667), a novel post-hoc explanation method for tabular data that generate local interpretable surrogates from globally-trained meta-encoder networks. 

To run the method, see [the quickstart](https://github.com/simonepiaggesi/illume/blob/main/examples/quickstart.py) or the
[notebook](https://github.com/simonepiaggesi/illume/blob/main/examples/illume_example.ipynb). Run the notebook from the repository
root so it can find the example datasets. The [Appendix](https://github.com/simonepiaggesi/illume/blob/main/appendix.pdf) describes
the experimental settings.

Paper: Simone Piaggesi, Riccardo Guidotti, Fosca Giannotti, and Dino Pedreschi. "Explanations go linear: Post-hoc explainability for tabular data with interpretable meta-encoding." In 2025 IEEE International Conference on Data Mining (ICDM), pp. 663-672. IEEE, 2025. [[link]](https://ieeexplore.ieee.org/abstract/document/11391937/)

## Installation

```bash
pip install "mimosa-illume[model]"
```

From a local clone, use `pip install -e ".[model,dev]"` to run the smoke test and
quickstart. Use `pip install -e ".[notebook]"` for the notebook or
`pip install -e ".[paper]"` for the experiment scripts.

## Basic usage 

```python
import numpy as np
from illume import ILLUME

X_train = np.random.default_rng(1).normal(size=(8, 3))
X_val = np.random.default_rng(2).normal(size=(4, 3))
model = ILLUME(latent_dim=2, max_epochs=1, batch_size=4)
model.fit(
    X=(X_train, X_val),
    idx_num_cat=[[0], [1], [2]],
    params_dict={"num_k": None, "l_rec": 0.0, "l_kld": 1.0,
                 "l_so": 0.0, "l_co": 0.0, "l_st": 0.0},
)
W, Z = model.transform(X_val)
```

Full example: `examples/illume_example.ipynb`.

## Reproduce paper experiments

After installing the `paper` extra, run scripts from the repository root, for
example:

```bash
python -m paper.scripts.train_eval_feature_importance --dataset breast --bb xgb --seed 0
python -m paper.scripts.baseline_eval_feature_importance --dataset breast --bb xgb --seed 0
```

Run a `train_eval_*.py` script for the same dataset, black-box model, and seed
before a real-data `baseline_eval_*.py` script. The baseline scripts load the
black-box model saved by the training scripts. The SENECA scripts generate their
own data and can run independently.

Generated files are stored under `paper/`: `blackboxes/` contains
saved black-box estimators (`.p`), `models/` contains ILLUME weights (`.pt`)
and surrogate descriptions (`.pkl`), and `results/` contains explanation and
evaluation pickles (`.pkl`). These generated directories are excluded by
`.gitignore`.

For the experiments with feature importance and real data:
- ILLUME: [train_eval_feature_importance.py](https://github.com/simonepiaggesi/illume/blob/main/paper/scripts/train_eval_feature_importance.py)
- LIME, SHAP, INP-LR: [baseline_eval_feature_importance.py](https://github.com/simonepiaggesi/illume/blob/main/paper/scripts/baseline_eval_feature_importance.py)

For the experiments with decision rules and real data:
- ILLUME: [train_eval_decision_rule.py](https://github.com/simonepiaggesi/illume/blob/main/paper/scripts/train_eval_decision_rule.py)
- LORE, ANCHOR, INP-DT: [baseline_eval_decision_rule.py](https://github.com/simonepiaggesi/illume/blob/main/paper/scripts/baseline_eval_decision_rule.py)

For the experiments with SENECA synthetic data:
- ILLUME: [seneca_train_eval_feature_importance.py](https://github.com/simonepiaggesi/illume/blob/main/paper/scripts/seneca_train_eval_feature_importance.py) and [seneca_train_eval_decision_rule.py](https://github.com/simonepiaggesi/illume/blob/main/paper/scripts/seneca_train_eval_decision_rule.py) 
- Competitors: [seneca_baseline_eval_feature_importance.py](https://github.com/simonepiaggesi/illume/blob/main/paper/scripts/seneca_baseline_eval_feature_importance.py) and [seneca_baseline_eval_decision_rule.py](https://github.com/simonepiaggesi/illume/blob/main/paper/scripts/seneca_baseline_eval_decision_rule.py) 

## Cite us

If you use the code in this repository, please consider citing us:

```bibtex
@inproceedings{piaggesi2025explanations,
  title={Explanations go linear: Post-hoc explainability for tabular data with interpretable meta-encoding},
  author={Piaggesi, Simone and Guidotti, Riccardo and Giannotti, Fosca and Pedreschi, Dino},
  booktitle={2025 IEEE International Conference on Data Mining (ICDM)},
  pages={663--672},
  year={2025},
  organization={IEEE}
}
```
