Privacy-Preserving Explainable AI Library for Financial Services
Project description
XFIN-XAI: Explainable AI Library for Financial Services and Banking Systems
XFIN-XAI is an open-source Python library designed for privacy-preserving explainable AI (XAI) in financial services and banking systems. It enables banks and financial institutions to generate transparent explanations for black-box models without exposing proprietary internals. The MVP focuses on credit risk explanations, adverse action notices, and counterfactual recommendations, ensuring compliance with regulations like GDPR and ECOA.
This library is built for educational and research purposes, allowing users to explore XAI in finance while maintaining data privacy.
Features
- Privacy-Preserving Explanations: Integrates SHAP and LIME for local explanations using only model predictions (no access to internals).
- Credit Risk Module: Generates feature importances, adverse action notices, and actionable recommendations.
- Compliance Engine: Produces regulatory-compliant reports and audit trails.
- LLM Integration: Uses Gemini (or similar) for natural language explanations and recommendations.
- Modular Design: Easily extensible for other domains (e.g., ESG, stress testing) in future versions.
- Efficient and Scalable: Runs on commodity hardware with low resource usage.
Installation
Install XFIN via pip:
pip install xfin-xai
For development installation, clone the repository and install dependencies:
git clone https://github.com/dhruvparmar10/XFIN.git
cd XFIN
pip install -e .
Requirements
- Python 3.8+
- Dependencies:
pandas,numpy,shap,lime,joblib,matplotlib,streamlit,(Open router for LLM features)
See requirements.txt for the full list.
Quick Start
Here's a basic example to get started with credit risk explanations:
import pandas as pd
import joblib
from xfin_xai import CreditRiskModule
# Load your black-box model (example)
model = joblib.load('path/to/your/model.pkl')
# Define a wrapper for your model (only expose predict/predict_proba)
class BankModel:
def predict(self, X):
return model.predict(X)
def predict_proba(self, X):
return model.predict_proba(X)
# Sample input data (replace with your features)
sample_data = pd.DataFrame({
'Annual_income': ,
'Employed_days': , # Add other features as per your dataset
})
# Initialize the explainer
explainer = CreditRiskModule(BankModel(), domain="credit_risk")
# Generate explanation
explanation = explainer.explain_prediction(sample_data)
# Generate recommendations
recommendations = explainer.generate_recommendations(sample_data)
# Generate compliance notice
compliance = explainer.generate_adverse_action_notice(explanation)
print("Prediction Explanation:", explanation)
print("Recommendations:", recommendations)
print("Adverse Action Notice:", compliance)
For more details, see the examples directory.
Documentation
Full documentation is available at xfin-xai.readthedocs.io.
Contributing
We welcome contributions! Please see our CONTRIBUTING.md for guidelines.
- Fork the repository.
- Create a feature branch (
git checkout -b feature/YourFeature). - Commit your changes (
git commit -m 'Add YourFeature'). - Push to the branch (
git push origin feature/YourFeature). - Open a Pull Request.
For bugs or feature requests, open an issue on GitHub.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Acknowledgments
- Major Thanks to Shap and Lime for building great tools.
- Thanks to the open-source community for tools like setuptools and ReadTheDocs.
For questions, contact [dhruv.jparmar0@gmail.com] or open an issue.
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 xfin_xai-0.1.0.tar.gz.
File metadata
- Download URL: xfin_xai-0.1.0.tar.gz
- Upload date:
- Size: 13.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
468ba181d9e84ae2dbcba112732706df5f79335bef86a75c202d6491e7f4c450
|
|
| MD5 |
ecde8bcc79e40a910fa7075138c99e32
|
|
| BLAKE2b-256 |
4eb5eb2fdba070949103e4acaacb41dbe2f3b58cc6af601b203a03234a9be8ab
|
Provenance
The following attestation bundles were made for xfin_xai-0.1.0.tar.gz:
Publisher:
python-publish.yml on DhruvParmar10/XFIN
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
xfin_xai-0.1.0.tar.gz -
Subject digest:
468ba181d9e84ae2dbcba112732706df5f79335bef86a75c202d6491e7f4c450 - Sigstore transparency entry: 453848623
- Sigstore integration time:
-
Permalink:
DhruvParmar10/XFIN@9d0ebe3bd6f8cf5e961bbac5f80e70c66e5a49f1 -
Branch / Tag:
refs/tags/scratch4 - Owner: https://github.com/DhruvParmar10
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@9d0ebe3bd6f8cf5e961bbac5f80e70c66e5a49f1 -
Trigger Event:
release
-
Statement type:
File details
Details for the file xfin_xai-0.1.0-py3-none-any.whl.
File metadata
- Download URL: xfin_xai-0.1.0-py3-none-any.whl
- Upload date:
- Size: 12.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
80be9bda007de5b9456373f3960b5ebdbfc56e3b94bf63caab0f001bafca690c
|
|
| MD5 |
bb236b4727cbf6af6125330271eb8182
|
|
| BLAKE2b-256 |
a53cba3e7247f812f884d7ea33d8f7afad4ff42c39402ae2eb862dedafe39f35
|
Provenance
The following attestation bundles were made for xfin_xai-0.1.0-py3-none-any.whl:
Publisher:
python-publish.yml on DhruvParmar10/XFIN
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
xfin_xai-0.1.0-py3-none-any.whl -
Subject digest:
80be9bda007de5b9456373f3960b5ebdbfc56e3b94bf63caab0f001bafca690c - Sigstore transparency entry: 453848625
- Sigstore integration time:
-
Permalink:
DhruvParmar10/XFIN@9d0ebe3bd6f8cf5e961bbac5f80e70c66e5a49f1 -
Branch / Tag:
refs/tags/scratch4 - Owner: https://github.com/DhruvParmar10
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@9d0ebe3bd6f8cf5e961bbac5f80e70c66e5a49f1 -
Trigger Event:
release
-
Statement type: