Skip to main content

EazyML Responsible-AI: XAI

Python PyPI package Code Style

EazyML

eazyml-xai is a python package designed to make machine learning predictions more transparent and interpretable. It provides human-readable explanations for predictions.

Features

  • Local Feature Importance: Get insights into the most impactful features influencing the predicted target variable.
  • Explanations: Explains the reason behind the predicted target variable.
  • Explainability Score: Enhance the reliability of explanations with an explainability score.

eazyml-xai is a key tool for building trust in AI systems by providing clear, actionable explanations.

Installation

To use the explainable ai, ensure you have Python installed on your system.

User installation

The easiest way to install EazyML Explainable AI is using pip:

pip install -U eazyml-xai

Dependencies

This package requires:

  • pandas
  • scikit-learn
  • werkzeug
  • Unidecode
  • pydot
  • numpy
  • pyyaml
  • xgboost

Usage

Example 1 - Fetching explanations with the EazyML model.

Imports

from eazyml_xai import ez_init, ez_explain

Initialize and Read Data

# Initialize the EazyML automl library.
_ = ez_init()

# Load training data (Replace with the correct data path).
train_data_path = "path_to_your_training_data.csv"
train = pd.read_csv(train_data_path)

# Load test data (Replace with the correct data path).
test_data_path = "path_to_your_test_data.csv"
test = pd.read_csv(test_data_path)

Fetch Explanations

# Define the outcome (target variable)
outcome = "target"  # Replace with your target variable name

# Build EazyML predictive models
build_options = {'model_type': 'predictive'}
build_resp = ez_build_model(train, outcome=outcome, options=build_options)

# Use model_info from ez_build_model response
model_info = build_resp["model_info"]

# Customize options for fetching explanations
xai_options = {"record_number": [1, 2, 3]}

# To fetch the explanations
xai_response = ez_explain(train, outcome, test_data_path, model_info, options=xai_options)

# xai_response is a dictionary object with following keys.
# print (xai_response.keys())
# dict_keys(['success', 'message', 'explanations'])

# reponse object contains a dictionary with explanations for the user specified record numbers. 

Example 2 - Fetching explanations with your model and EazyML preprocessing.

Imports

from eazyml_xai import ez_init, ez_explain, create_onehot_encoded_features, ez_get_data_type

Initialize and Read Data

# Initialize the EazyML automl library.
_ = ez_init()

# Load training data (Replace with the correct data path).
train_data_path = "path_to_your_training_data.csv"
train = pd.read_csv(train_data_path)

# Define input features (X) and target variable (y)
y = train[outcome]
X = train.drop(outcome, axis=1)

# Load test data (Replace with the correct data path).
test_data_path = "path_to_your_test_data.csv"
test = pd.read_csv(test_data_path)

Fetch Explanations

# Define the outcome (target variable)
outcome = "target"  # Replace with your target variable name

# Get data type of features
type_df = ez_get_data_type(train, outcome)

# List of categorical columns
cat_list = type_df[type_df['Data Type'] == 'categorical']['Variable Name'].tolist()
cat_list = [ele for ele in cat_list if ele != outcome]

# Create one-hot encoded features
train = create_onehot_encoded_features(train, cat_list)

# Define your model object (replace with any model of your choice)
model_info = <YourModelClass>(<parameters>)  # e.g., RandomForestClassifier(), LogisticRegression(), etc.

# Train your model object
model_info.fit(X, y)

# Customize options for fetching explanations
xai_options = {"record_number": [1, 2, 3]}

# To fetch the explanations
xai_response = ez_explain(train, outcome, test_data_path, model_info, options=xai_options)

# xai_response is a dictionary object with following keys.
# print (xai_response.keys())
# dict_keys(['success', 'message', 'explanations'])

# reponse object contains a dictionary with explanations for the user specified record numbers. 

Example 3 - Fetching explanations with your model and preprocessing.

Imports

from eazyml_xai import ez_init, ez_explain

Initialize and Read Data

# Initialize the EazyML automl library.
_ = ez_init()

# Load training data (Replace with the correct data path).
train_data_path = "path_to_your_training_data.csv"
train = pd.read_csv(train_data_path)

# Define input features (X) and target variable (y)
y = train[outcome]
X = train.drop(outcome, axis=1)

# Load test data (Replace with the correct data path).
test_data_path = "path_to_your_test_data.csv"
test = pd.read_csv(test_data_path)

Fetch Explanations

# Define the outcome (target variable)
outcome = "target"  # Replace with your target variable name

# Implement your preprocessing steps within a custom preprocessor class and define it
# (Replace <YourPreprocessorClass> with the specific preprocessor class you're using)
preprocessor = <YourPreprocessorClass>(<parameters>)  # Example: StandardScaler(), CustomPreprocessor()

# Fit the preprocessor on your dataset
preprocessor.fit(X, y)

# Define your model object (replace with any model of your choice)
model_info = <YourModelClass>(<parameters>)  # e.g., RandomForestClassifier(), LogisticRegression(), etc.

# Train your model object
model_info.fit(X, y)

# Customize options for fetching explanations
xai_options = {"record_number": [1, 2, 3], "preprocessor", preprocessor}

# To fetch the explanations
xai_response = ez_explain(train_data_path, outcome, test_data_path, model_info, options=xai_options)

# xai_response is a dictionary object with following keys.
# print (xai_response.keys())
# dict_keys(['success', 'message', 'explanations'])

# reponse object contains a dictionary with explanations for the user specified record numbers. 

You can find more information in the documentation.

  • Documentation

  • Homepage

  • 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.

Release files for eazyml-xai 0.0.94

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for eazyml-xai 0.0.94
File Size Uploaded
eazyml_xai-0.0.94.tar.gz 41.5 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for eazyml-xai 0.0.94
File Interpreter ABI Platform
eazyml_xai-0.0.94-py2.py3-none-any.whl Python 3, Python 2 none any Details

Total release size: 83.7 MB

Release files / eazyml_xai-0.0.94.tar.gz

Download URL eazyml_xai-0.0.94.tar.gz
Size 41.5 MB
Tags Source
SHA-256 checksum
How to use checksums
256a4687bbb9b7dbd586b549f829895e645e4dfb883b98f2e336e29187130b45
BLAKE2b-256 checksum
How to use checksums
b7bac7f7ce0626748eba2aeebddee344bf0db05d2c5c0431f6815a2ab9940e76
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.14

Release files / eazyml_xai-0.0.94-py2.py3-none-any.whl

Download URL eazyml_xai-0.0.94-py2.py3-none-any.whl
Size 42.2 MB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
88868532cb1e97aaa6ce64c6cd84846f02934ea83f117e825d9047265e8653b5
BLAKE2b-256 checksum
How to use checksums
1a4176abd6f5aeaa58212c3664fe7545d57570dd5c746afc5d9b9e4941340a1c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.14

Release history Release notifications | RSS feed

This release

0.0.94 This release

2 release files

0.0.93

2 release files

0.0.92

2 release files

0.0.91

2 release files

0.0.86

2 release files

0.0.82

2 release files

0.0.81

2 release files

0.0.80

2 release files

0.0.79

2 release files

0.0.78

2 release files

0.0.76

1 release file

0.0.75

1 release file

0.0.73

2 release files

0.0.67

2 release files

0.0.65

2 release files

0.0.64

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page