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

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.93
File Size Uploaded
eazyml_xai-0.0.93.tar.gz 6.9 MB Details

Built distribution (wheel)

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

Total release size: 14.0 MB

Release files / eazyml_xai-0.0.93.tar.gz

Download URL eazyml_xai-0.0.93.tar.gz
Size 6.9 MB
Tags Source
SHA-256 checksum
How to use checksums
675a00884e925db5e3541262bd22b85989001bc693f5065233e2b57dbb1619a5
BLAKE2b-256 checksum
How to use checksums
549c884fe1bf8292c9f800344e65861ee2023603e40e41dad0eaac58d4e0fadc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.8.20

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

Download URL eazyml_xai-0.0.93-py2.py3-none-any.whl
Size 7.1 MB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
90826846b0a53162aa691ace7ca2fc73675a0db4891269acebc4d8926948e103
BLAKE2b-256 checksum
How to use checksums
c6c21c6b34419793155648a64099268bddbd4cdbebda484ac36b85b258729e8c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.8.20

Release history Release notifications | RSS feed

0.0.94

2 release files

This release

0.0.93 This release

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