DiCE review
A free Python library for exploring alternative predictions with configurable counterfactuals.
Reviewed by iTechGuides Editors · Editorial team · Updated Oct 2026
DiCE is an open-source Python library from Microsoft Research for generating diverse counterfactual explanations of machine-learning predictions. It is aimed at developers and researchers who want to examine how alternative input values could change a model output. Its examples cover classification and regression with scikit-learn, TensorFlow, and PyTorch models, and it can work with pre-trained models with or without access to the full training dataset.
The main strength is control over counterfactual generation. Users can configure diversity and proximity, set feature constraints and permitted ranges, and select which features may vary. DiCE provides model-agnostic randomized sampling, KD-tree, and genetic search methods, as well as gradient-based generation for differentiable models. It also derives local feature-importance scores from counterfactuals and can show results in tabular form or save them. Feature metadata can be used instead of the full sensitive dataset, which may suit workflows where that dataset is not available to the explanation step.
DiCE is free and self-hosted, with Linux, Windows, and macOS listed as platforms. Its fit is strongest for teams that can work in Python and specifically need actionable alternative examples; its documented connections to scikit-learn, TensorFlow, and PyTorch support those model workflows. The tradeoff is a narrower scope than a general explainability suite: it focuses on counterfactuals and related local importance, and fairness evaluation is not currently provided. Choose DiCE when counterfactual exploration is the central task; consider another tool if fairness analysis or a broader explanation workflow is required.
DiCE pros and cons
- Where it wins
- Generates multiple counterfactuals with configurable diversity and proximity
- Offers feature constraints and randomized, KD-tree, and genetic search
- Works with scikit-learn, TensorFlow, and PyTorch models
- Where it doesn't
- Focused on counterfactual explanations rather than broad explainability
- Does not currently provide fairness evaluation
- Requires a developer workflow as a Python library, not a hosted service
DiCE fact sheet, pricing and score →
Advertiser disclosure: iTechGuides is reader-supported. Vendors can pay for top positions in our rankings and for a place on other products' pages, and we may earn a commission when you click some links. How we rank.
Last updated · How we research and update