Skip to main content

Regulation-aware ML pipeline for finance

Project description

finreg-ml

CI Python 3.9+ License: MIT

Regulation-aware ML pipeline for finance. Train a model, get a compliance report.

Built for teams shipping ML in regulated industries (credit scoring, fraud detection, insurance pricing) who need explainability, fairness audits, and EU AI Act documentation as part of their workflow — not as an afterthought.

Installation

pip install finreg-ml

Quick Start

from finreg import GovernedModel
from sklearn.ensemble import GradientBoostingClassifier

# Wrap any sklearn-compatible estimator
model = GovernedModel(
    estimator=GradientBoostingClassifier(),
    protected_attributes=["age_group", "gender"],
    risk_tier="high",  # EU AI Act classification
    model_name="CreditScorer",
)

# Train — metadata captured automatically
model.fit(X_train, y_train)

# Evaluate
metrics = model.evaluate(X_test, y_test)

# Explain — SHAP values auto-generated
explanations = model.explain(X_test)
print(explanations.top_features(5))

# Fairness audit — bias metrics across protected attributes
fairness = model.fairness_report(X_test, y_test)
for report in fairness:
    print(f"{report.attribute}: disparate impact = {report.disparate_impact_ratio:.3f}")

# Compliance check — EU AI Act Article 13 assessment
compliance = model.compliance_report()
print(f"Compliant: {compliance.compliant}")
print(f"Passed: {compliance.passed}, Failed: {compliance.failed}")

# Export everything
model.model_card().to_json("model_card.json")
model.audit_log.to_json("audit_log.json")
compliance.to_json("compliance_report.json")

What It Does

Module Purpose
GovernedModel Sklearn-compatible wrapper that captures training metadata automatically
finreg.explain SHAP-based explanations and feature importance
finreg.fairness Demographic parity, equalized odds, disparate impact (four-fifths rule)
finreg.model_card Auto-generated model cards (Google Model Card spec)
finreg.compliance EU AI Act compliance assessment (Articles 5, 10, 12, 13, 14, 15)
finreg.audit Append-only audit log with SHA-256 integrity checksums

EU AI Act Coverage

Checks against these articles for HIGH-risk systems:

  • Article 5 — Prohibited AI practices detection
  • Article 10 — Data governance requirements
  • Article 12 — Automatic logging and traceability
  • Article 13 — Transparency and explainability
  • Article 14 — Human oversight mechanisms
  • Article 15 — Accuracy metrics and bias testing

Fairness Metrics

For each protected attribute, computes:

  • Demographic parity difference — gap in positive prediction rates across groups
  • Equalized odds difference — gap in true positive rates
  • Disparate impact ratio — ratio of lowest to highest positive rate
  • Four-fifths rule — passes if disparate impact ratio >= 0.8

Development

git clone https://github.com/atharvajoshi01/finreg-ml.git
cd finreg-ml
pip install -e ".[dev]"
pytest

License

MIT

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

finreg_ml-0.1.0.tar.gz (17.0 kB view details)

Uploaded Source

Built Distribution

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

finreg_ml-0.1.0-py3-none-any.whl (16.2 kB view details)

Uploaded Python 3

File details

Details for the file finreg_ml-0.1.0.tar.gz.

File metadata

  • Download URL: finreg_ml-0.1.0.tar.gz
  • Upload date:
  • Size: 17.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.7

File hashes

Hashes for finreg_ml-0.1.0.tar.gz
Algorithm Hash digest
SHA256 6d551b041223ec2f19549f31bf37d4c9495e4b1a25365e85baff4dc8ae1024b8
MD5 275c6f6ddf9092863bdda1f6cf325186
BLAKE2b-256 33ba05c15aef34d920ee0e4edaaf214837a01b6135d2aab15afa228b245977b0

See more details on using hashes here.

File details

Details for the file finreg_ml-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: finreg_ml-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 16.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.7

File hashes

Hashes for finreg_ml-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 85b01448ec05decda648051d7320a6bc09d44125778475ce08b814a135509132
MD5 3a2ce5a8f35925ab1e69c3e406e90340
BLAKE2b-256 9aa1d1165cdc97a3f7a95085403c549452a9d65e8b0b0d263621ad04e092f874

See more details on using hashes here.

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