Metadata-Version: 2.1
Name: XplainML
Version: 0.0.1
Summary: XplainML is a comprehensive Python package designed for Explainable AI (XAI) and Responsible AI practices. It provides a suite of tools and algorithms to enhance the transparency, interpretability, and fairness of machine learning models.
Home-page: https://github.com/DeependraVerma/XAI_ResponsibleAI_Toolbox
Author: DeependraVerma
Author-email: deependra.verma00@gmail.com
License: MIT
Project-URL: Bug Tracker, https://github.com/DeependraVerma/XAI_ResponsibleAI_Toolbox/issues
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Operating System :: OS Independent
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: pandas
Requires-Dist: numpy
Requires-Dist: scikit-learn
Requires-Dist: shap
Requires-Dist: lime
Requires-Dist: aif360
Requires-Dist: fairlearn
Requires-Dist: seaborn
Requires-Dist: matplotlib
Requires-Dist: scikit-image
Provides-Extra: testing
Requires-Dist: tox==3.25.1; extra == "testing"
Requires-Dist: tox-gh-actions; extra == "testing"
Requires-Dist: pytest>=7.1.3; extra == "testing"
Requires-Dist: black>=22.8.0; extra == "testing"
Requires-Dist: flake8>=5.0.4; extra == "testing"
Requires-Dist: mypy>=0.971; extra == "testing"

# XplainML: Empowering Transparent and Responsible AI

[![GitHub stars](https://img.shields.io/github/stars/DeependraVerma/XAI_ResponsibleAI_Toolbox.svg)](https://github.com/DeependraVerma/XAI_ResponsibleAI_Toolbox/stargazers)
[![GitHub license](https://img.shields.io/github/license/DeependraVerma/XAI_ResponsibleAI_Toolbox.svg)](https://github.com/DeependraVerma/XAI_ResponsibleAI_Toolbox/blob/main/LICENSE)

Welcome to XplainML – your ultimate toolkit for unlocking the power of transparent and responsible AI! Designed and developed by [Deependra Verma](https://www.linkedin.com/in/deependra-verma-data-science/), XplainML empowers data scientists, machine learning engineers, and AI practitioners to understand, interpret, and trust their models with ease.

## Introduction

XplainML is an open-source Python package designed to provide transparent and responsible AI capabilities to users. With XplainML, you can easily interpret your AI models, detect and mitigate bias, ensure fairness, and promote ethical AI practices.

## Features

### Explainable AI (XAI) Made Easy

Unravel the mysteries of your AI models with intuitive explanations using state-of-the-art techniques like SHAP and LIME.

### Responsible AI Integration

Detect and mitigate bias, ensure fairness, and promote ethical AI practices with built-in fairness metrics and bias mitigation algorithms.

## Installation

To install XplainML, simply run:

```bash
pip install XplainML
```

## Usage

### Explainable AI (XAI)

#### SHAP Explanations

```python
# Import the necessary libraries
import shap
from sklearn.datasets import load_iris
from sklearn.ensemble import RandomForestClassifier

# Load the Iris dataset
iris = load_iris()
X, y = iris.data, iris.target

# Train a random forest classifier
model = RandomForestClassifier(n_estimators=100, random_state=42)
model.fit(X, y)

# Initialize the SHAP explainer
explainer = shap.Explainer(model)

# Generate SHAP explanations for a sample instance
shap_values = explainer(X[:1])

# Visualize the SHAP explanations
shap.plots.waterfall(shap_values[0])
```

#### LIME Explanations

```python
# Import the necessary libraries
import lime
import lime.lime_tabular
from sklearn.datasets import load_iris
from sklearn.ensemble import RandomForestClassifier

# Load the Iris dataset
iris = load_iris()
X, y = iris.data, iris.target

# Train a random forest classifier
model = RandomForestClassifier(n_estimators=100, random_state=42)
model.fit(X, y)

# Initialize the LIME explainer
explainer = lime.lime_tabular.LimeTabularExplainer(X, feature_names=iris.feature_names, class_names=iris.target_names)

# Generate LIME explanations for a sample instance
explanation = explainer.explain_instance(X[0], model.predict_proba)

# Visualize the LIME explanations
explanation.show_in_notebook()
```

### Responsible AI Integration

#### Bias Detection

```python
# Import the necessary libraries
from aif360.datasets import GermanDataset
from aif360.metrics import BinaryLabelDatasetMetric

# Load the German credit dataset
dataset = GermanDataset()
privileged_group = [{'sex': 1}]
unprivileged_group = [{'sex': 0}]

# Compute metrics for bias detection
metric = BinaryLabelDatasetMetric(dataset, unprivileged_group=unprivileged_group, privileged_group=privileged_group)
print("Mean Difference: ", metric.mean_difference())
print("Disparate Impact: ", metric.disparate_impact())
```

#### Bias Mitigation

```python
# Import the necessary libraries
from aif360.algorithms.preprocessing import Reweighing

# Apply bias mitigation using Reweighing
biased_dataset = dataset.convert_to_dataframe()[0]
rw = Reweighing(unprivileged_groups=unprivileged_group, privileged_groups=privileged_group)
biased_dataset = rw.fit_transform(biased_dataset)

# Verify bias mitigation results
metric_biased = BinaryLabelDatasetMetric(biased_dataset, unprivileged_group, privileged_group)
print("Mean Difference after mitigation: ", metric_biased.mean_difference())
print("Disparate Impact after mitigation: ", metric_biased.disparate_impact())
```

## Contributing

We welcome contributions from the community! Whether it's fixing bugs, adding new features, or improving documentation, your contributions help make XplainML better for everyone. Check out our [Contributing Guidelines](https://github.com/DeependraVerma/XAI_ResponsibleAI_Toolbox/blob/main/CONTRIBUTING.md) to get started.

## License

XplainML is licensed under the [MIT License](https://github.com/DeependraVerma/XAI_ResponsibleAI_Toolbox/blob/main/LICENSE). See the [LICENSE](https://github.com/DeependraVerma/XAI_ResponsibleAI_Toolbox/blob/main/LICENSE) file for details.

## About the Author

**Deependra Verma**  
*Data Scientist*  
[Email](mailto:deependra.verma00@gmail.com) | [LinkedIn](https://www.linkedin.com/in/deependra-verma-data-science/) | [GitHub](https://github.com/DeependraVerma) | [Portfolio](https://deependradatascience-productportfolio.netlify.app/)
```
