Skip to main content

Privacy-Preserving Explainable AI Library for Financial Services and Banking Systems

Project description

XFIN-XAI: Privacy-Preserving Explainable AI for Financial Services

PyPI version Documentation Status License: MIT

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.

🤝 Contributing

We welcome contributions! Please see our CONTRIBUTING.md for guidelines.

How to Contribute

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/YourFeature)
  3. Commit your changes (git commit -m 'Add YourFeature')
  4. Push to the branch (git push origin feature/YourFeature)
  5. 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:


Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

xfin_xai-0.1.2.tar.gz (16.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

xfin_xai-0.1.2-py3-none-any.whl (15.5 kB view details)

Uploaded Python 3

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

Hashes for xfin_xai-0.1.2.tar.gz
Algorithm Hash digest
SHA256 6e3c53ffbf4f5c18fcbd083c3b60d95cda69bb9be54564893a5ac2669f1ab05b
MD5 ded1d5061d5fc0de6ed68222bdb81776
BLAKE2b-256 4bf1403f71abf3885e45052c6363e08ca6d336a9906e416310741f250572c074

See more details on using hashes here.

Provenance

The following attestation bundles were made for xfin_xai-0.1.2.tar.gz:

Publisher: python-publish.yml on DhruvParmar10/XFIN

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for xfin_xai-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 06694bf0c8ffd903bedbd69f544d9aa21de37d0dce97a06135f7b4f4f33ccb5b
MD5 a23f892925b8b9cfe29f03b00d3b7dbe
BLAKE2b-256 2e774f1bea94794eb0ede922fd78e250209a8cf57c7412a82b6c8f3f1b2e2dae

See more details on using hashes here.

Provenance

The following attestation bundles were made for xfin_xai-0.1.2-py3-none-any.whl:

Publisher: python-publish.yml on DhruvParmar10/XFIN

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page