Privacy-Preserving Explainable AI Library for Financial Services and Banking Systems
Project description
XFIN-XAI: Privacy-Preserving Explainable AI for Financial Services
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 library focuses on credit risk explanations, adverse action notices, and counterfactual recommendations, ensuring compliance with regulations like GDPR and ECOA.
Note: 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
- 💳 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)
- ⚡ Efficient and Scalable: Runs on commodity hardware with low resource usage
📦 Installation
Quick Installation
pip install xfin-xai
Launch the Web Interface
After installation, launch the interactive web interface:
xfin credit
This will open the Streamlit web application where you can upload your model and dataset files.
Command Line Options
# Show help
xfin credit --help
# Launch on custom port
xfin credit --port 8502
# Launch on all interfaces
xfin credit --host 0.0.0.0
Development Installation
For development installation:
git clone https://github.com/dhruvparmar10/XFIN.git
cd XFIN
pip install -e .
🔧 Requirements
- Python: 3.9+
- Core Dependencies:
pandas,numpy,shap,lime,joblib,matplotlib,streamlit,scikit-learn - Optional: OpenRouter API key for LLM-powered explanations
See requirements.txt for the complete list.
🚀 Quick Start
Here's a basic example to get started with credit risk explanations:
import pandas as pd
import joblib
from XFIN import CreditRiskModule
# Load your black-box model
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': [50000],
'Employed_days': [1825],
'Credit_score': [650],
# Add other features as per your dataset
})
# Initialize the explainer with API key (optional)
explainer = CreditRiskModule(
BankModel(),
domain="credit_risk",
api_key="your-openrouter-api-key" # Optional for LLM explanations
)
# 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)
📖 Documentation
Full documentation is available at xfin-xai.readthedocs.io.
- 📚 API Reference
- 🎓 Tutorials
- 🗺️ Roadmap
🤝 Contributing
We welcome contributions! Please see our CONTRIBUTING.md for guidelines.
How to Contribute
- 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, please open an issue on GitHub.
📄 License
This project is licensed under the MIT License - see the LICENSE file for details.
🙏 Acknowledgments
- SHAP and LIME teams for building excellent explainability tools
- Open-source community for tools like setuptools and ReadTheDocs
- Financial AI research community for guidance on regulatory compliance
📞 Contact
For questions or support:
- Email: dhruv.jparmar0@gmail.com
- Issues: GitHub Issues
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.2.tar.gz.
File metadata
- Download URL: xfin_xai-0.1.2.tar.gz
- Upload date:
- Size: 16.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6e3c53ffbf4f5c18fcbd083c3b60d95cda69bb9be54564893a5ac2669f1ab05b
|
|
| MD5 |
ded1d5061d5fc0de6ed68222bdb81776
|
|
| BLAKE2b-256 |
4bf1403f71abf3885e45052c6363e08ca6d336a9906e416310741f250572c074
|
Provenance
The following attestation bundles were made for xfin_xai-0.1.2.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.2.tar.gz -
Subject digest:
6e3c53ffbf4f5c18fcbd083c3b60d95cda69bb9be54564893a5ac2669f1ab05b - Sigstore transparency entry: 532534572
- Sigstore integration time:
-
Permalink:
DhruvParmar10/XFIN@974bc141df79f28a026ff4e4204d52b6bd0a3fd4 -
Branch / Tag:
refs/tags/v0.1.2-scratch - Owner: https://github.com/DhruvParmar10
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@974bc141df79f28a026ff4e4204d52b6bd0a3fd4 -
Trigger Event:
release
-
Statement type:
File details
Details for the file xfin_xai-0.1.2-py3-none-any.whl.
File metadata
- Download URL: xfin_xai-0.1.2-py3-none-any.whl
- Upload date:
- Size: 15.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
06694bf0c8ffd903bedbd69f544d9aa21de37d0dce97a06135f7b4f4f33ccb5b
|
|
| MD5 |
a23f892925b8b9cfe29f03b00d3b7dbe
|
|
| BLAKE2b-256 |
2e774f1bea94794eb0ede922fd78e250209a8cf57c7412a82b6c8f3f1b2e2dae
|
Provenance
The following attestation bundles were made for xfin_xai-0.1.2-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.2-py3-none-any.whl -
Subject digest:
06694bf0c8ffd903bedbd69f544d9aa21de37d0dce97a06135f7b4f4f33ccb5b - Sigstore transparency entry: 532534574
- Sigstore integration time:
-
Permalink:
DhruvParmar10/XFIN@974bc141df79f28a026ff4e4204d52b6bd0a3fd4 -
Branch / Tag:
refs/tags/v0.1.2-scratch - Owner: https://github.com/DhruvParmar10
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@974bc141df79f28a026ff4e4204d52b6bd0a3fd4 -
Trigger Event:
release
-
Statement type: