eazyml-counterfactual from EazyML family for counterfactual explanations, prescriptive analytics, and actionable insights to optimize predictive outcomes.
Project description
EazyML Responsible-AI: Counterfactual
eazyml-counterfactual is a python package that helps users optimize predictive outcomes by generating counterfactual explanations.
EazyML revolutionizes machine learning by introducing counterfactual inference, automating the process of identifying optimal changes to variables that shift outcomes from unfavorable to favorable. This approach overcomes the limitations of manual "what-if" analysis, enabling models to provide actionable, prescriptive insights alongside their predictions.
Designed for post-prediction analysis, the package answers questions like:
- "What minimal changes to input features can reverse an unfavorable prediction?"
- "How can I achieve a desired outcome by tweaking feature values?"
Features
- Counterfactual Explanations: Identify feature changes required to alter predictions.
- Prescriptive Analytics: Generate actionable recommendations to achieve better outcomes.
- It performs feature selection from a training dataset by excluding specific columns and the target outcome column.
- This function builds a machine learning model using a specified training dataset.
- It provides platform to automates counterfactual inference for a test record by calculating the probability of an unfavorable outcome and determining the optimal adjustments to minimize it. It processes input datasets, configuration parameters, and model details to identify actionable changes in features while respecting constraints, enabling prescriptive insights for improved outcomes.
eazyml-counterfactual is ideal for scenarios like fraud detection, loan approvals, and customer churn prevention.`
Installation
User installation
The easiest way to install counterfactual package is using pip:
pip install -U eazyml-counterfactual
Dependencies
EazyML Counterfactual requires :
- pandas
- matplotlib
- openpyxl
- scikit-learn
- scipy
- pyyaml
Usage
Counterfactual can be used by initalizing EazyML and then getting insights for new test data.
from eazyml_counterfactual import ez_init, ez_cf_inference
# initialize: setup book-keeping, access_key if required
_ = ez_init()
selected_features = ['list of all the selected features in train data']
variants = ['list of features to be varied']
# Defining configurable parameters for counterfactual inference
options = {
"variants": variants,
"outcome_ordinality": "1", # Desired outcome to transition to, can also specify "minimize" or "maximize"
"train_data": train_file
}
# Specify the index of the test record for which counterfactual inference will be performed
test_index_no = 0
# pred_df it contains test dataframe with predicted output for outcome in probability term.
test_data = pred_df.loc[[test_index_no]]
result = ez_cf_inference(
test_data,
outcome,
selected_features,
model_info,
options
)
You can find more information in the documentation.
Useful links, other packages from EazyML family
-
If you have questions or would like to discuss a use case, please contact us here
-
Here are the other packages from EazyML suite:
- eazyml-automl: eazyml-automl provides a suite of APIs for training, optimizing and validating machine learning models with built-in AutoML capabilities, hyperparameter tuning, and cross-validation.
- eazyml-data-quality: eazyml-data-quality provides APIs for comprehensive data quality assessment, including bias detection, outlier identification, and drift analysis for both data and models.
- eazyml-counterfactual: eazyml-counterfactual provides APIs for optimal prescriptive analytics, counterfactual explanations, and actionable insights to optimize predictive outcomes to align with your objectives.
- eazyml-insight: eazyml-insight provides APIs to discover patterns, generate insights, and mine rules from your datasets.
- eazyml-xai: eazyml-xai provides APIs for explainable AI (XAI), offering human-readable explanations, feature importance, and predictive reasoning.
- eazyml-xai-image: eazyml-xai-image provides APIs for image explainable AI (XAI).
License
This project is licensed under the Proprietary License.
Maintained by EazyML
© 2025 EazyML. All rights reserved.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file eazyml_counterfactual-0.0.53.tar.gz.
File metadata
- Download URL: eazyml_counterfactual-0.0.53.tar.gz
- Upload date:
- Size: 8.8 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9ea32f2ecef49cdd15d678ffd1c2fb1c2f7d5db48e877feb8e6a14149a6046e9
|
|
| MD5 |
89b572f43ce084570fdab99dfc4f91b7
|
|
| BLAKE2b-256 |
ec9d550b9e768f67ebb50fa340790f4049b3da6e0d34db9961381636a262c701
|
File details
Details for the file eazyml_counterfactual-0.0.53-py2.py3-none-any.whl.
File metadata
- Download URL: eazyml_counterfactual-0.0.53-py2.py3-none-any.whl
- Upload date:
- Size: 9.2 MB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d59f4b7e9200c5100a32412ee3b1b6c1da332ecaa1458e2869a07a6df5eb00e3
|
|
| MD5 |
5e896680de39c015c6f3857484a267e3
|
|
| BLAKE2b-256 |
2f3b72a8e00f21dd0dd9c4f20b9c6434ea0ff3b64283dd0fc2dd015ce2c7e4d4
|