Skip to main content

Privacy-Preserving Explainable AI Library for Financial Services

Project description

XFIN-XAI: Explainable AI Library for Financial Services and Banking Systems

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 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.

  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, 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


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.0.tar.gz (13.4 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.0-py3-none-any.whl (12.3 kB view details)

Uploaded Python 3

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

Hashes for xfin_xai-0.1.0.tar.gz
Algorithm Hash digest
SHA256 468ba181d9e84ae2dbcba112732706df5f79335bef86a75c202d6491e7f4c450
MD5 ecde8bcc79e40a910fa7075138c99e32
BLAKE2b-256 4eb5eb2fdba070949103e4acaacb41dbe2f3b58cc6af601b203a03234a9be8ab

See more details on using hashes here.

Provenance

The following attestation bundles were made for xfin_xai-0.1.0.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.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

Hashes for xfin_xai-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 80be9bda007de5b9456373f3960b5ebdbfc56e3b94bf63caab0f001bafca690c
MD5 bb236b4727cbf6af6125330271eb8182
BLAKE2b-256 a53cba3e7247f812f884d7ea33d8f7afad4ff42c39402ae2eb862dedafe39f35

See more details on using hashes here.

Provenance

The following attestation bundles were made for xfin_xai-0.1.0-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