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
Metadata
Release files for xfin-xai 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| xfin_xai-0.1.2.tar.gz | 16.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| xfin_xai-0.1.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 31.6 kB
Release files / xfin_xai-0.1.2.tar.gz
| Download URL | xfin_xai-0.1.2.tar.gz |
|---|---|
| Size | 16.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6e3c53ffbf4f5c18fcbd083c3b60d95cda69bb9be54564893a5ac2669f1ab05b
|
|
BLAKE2b-256 checksum How to use checksums |
4bf1403f71abf3885e45052c6363e08ca6d336a9906e416310741f250572c074
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 18, 2025.
Transparency logRelease files / xfin_xai-0.1.2-py3-none-any.whl
| Download URL | xfin_xai-0.1.2-py3-none-any.whl |
|---|---|
| Size | 15.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
06694bf0c8ffd903bedbd69f544d9aa21de37d0dce97a06135f7b4f4f33ccb5b
|
|
BLAKE2b-256 checksum How to use checksums |
2e774f1bea94794eb0ede922fd78e250209a8cf57c7412a82b6c8f3f1b2e2dae
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 18, 2025.
Transparency log