VCNet Documentation
VCNet is a collection of counterfactual generators 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. 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. It requires a classifier that is a Torch module.
Post-hoc architecture: This version includes only the counterfactual generator, which can be fitted on any prediction model. The prediction model can be a deep learning model or a shallow learning model (including non-differentiable classifiers such as random forests).
Once the VCNet model is fitted, it can efficiently generate valid counterfactuals for given examples. To facilitate the use of VCNet on tabular datasets, we provide utilities to interact with pandas DataFrames.
VCNet’s implementation is based on Lightning. It defines:
A dataset class named
DataCatalog
, which handles dataset configuration, including feature characteristics (immutable, categorical).The
VCNet
andPHVCNet
modules, which implement the trainable joint-learning VCNet and the post-hoc VCNet models, respectively. In the joint-learning approach, the model trains both a classifier and a counterfactual generator. In the post-hoc approach, it trains only the generator (from a pre-trained classifier).
The instances of DataCatalog
and class models are parameterized using a dictionary that contains all the hyperparameters.
This implementation is compatible with hyperparameter optimization frameworks such as Hydronaut.
We invite the reader to explore the examples to learn how to use these models with their own data.
Citation
If you use this software, please cite our work:
@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}
}