Skip to main content

Counterfactual generation

Project description


title: README author: Thomas Guyet

PyPI version Downloads GitHub license Lightning Torch

VCNet: Variational Counter Net

This repository contains an enriched implementation of VCNet, a counterfactual generator for tabular datasets. Counterfactual generation is an explainable artificial intelligence technique that helps users understand the decisions of predictive models.

VCNet handles both categorical and numerical variables and can also manage immutable variables (i.e., variables that cannot be changed while generating counterfactuals). Currently, it is implemented for binary classification only. VCNet is based on conditional variational encoders which increases the realism of the generated counterfactuals. Compared to its competitors (see for instance jax-relax), VCNet offers an easy and fast training architecture that generates realistic counterfactuals (i.e., counterfactuals that likely exist in the data distribution).

This library provides two versions of VCNet:

  • Joint-learning architecture: This version includes both the classification model and the counterfactual generator.
  • Post-hoc architecture: This version includes only the counterfactual generator, which can be fitted on any probabilistic prediction model (torch modules, sklearn classifiers or XGBoost classifiers).

This library is enhanced by several practical features:

  • it is fully compatible with Pandas: the examples and the counterfactuals can be pandas dataframes, making it easy to integrate into a standard data analysis pipeline
  • handling categorical and immutable variables:
  • adding automatic rounding of numerical feature to augment the realism

Once the VCNet model is fitted, it can be used to generate efficiently valid counterfactuals of examples.


For more details about the features of the library, we invite you to take a look at the documentation and its examples.

Authors

This implementation is derived from the original work by V. Guyomard (CARLA CROCO VCNet). It is implemented as a PyTorch Lightning module for easy integration into your own architecture.

  • Thomas Guyet, Inria, AIstroSight
  • Victor Guyomard, Orange Labs

How to install

Installation with pip

VCNet is available on PyPi, the installation of the package and its dependencies is possible in a single line:

pip install VCNet

Installation from sources

The pyproject.toml is the project configuration file which enables to create and set up a virtual environment suitable to run VCNet.

  1. Download the code from gitlab
git clone https://gitlab.inria.fr/tguyet/vcnet.git
cd vcnet
  1. Install the dependencies
pip install -r requirements.txt

or, to install the package:

pip install -e .
  1. Test VCNet on Adult dataset
python tests/test_data.py

For more details, look at the documentation pages.

How to cite

@inproceedings{guyomard2022vcnet,
  title={VCNet: A self-explaining model for realistic counterfactual generation},
  author={Guyomard, Victor and Fessant, Fran{\c{c}}oise and Guyet, Thomas and Bouadi, Tassadit and Termier, Alexandre},
  booktitle={Joint European Conference on Machine Learning and Knowledge Discovery in Databases},
  pages={437--453},
  year={2022},
  organization={Springer}
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

vcnet-0.2.0-py3-none-any.whl (21.9 kB view details)

Uploaded Python 3

File details

Details for the file vcnet-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: vcnet-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 21.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for vcnet-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3a51b583a250df8d2415f29b0f65989d3e45753792edeb102bf1f6c58e54b804
MD5 60b731af68cc67f72db775e8ceeee51b
BLAKE2b-256 7a82d7de19b407b184de0c9b5e67ddc023b3903e3a03e304c209c46c215160d5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page