Unified Credit Decision Engine for Indian NBFC Lending - scoring, bureau, policy, risk, compliance
Project description
IndiaLend
Unified Credit Decision Engine for Indian NBFC Lending
One-stop Python library for Indian fintech credit decisioning: credit scoring, bureau integration, income verification, policy engine, risk assessment, and RBI compliance.
Why IndiaLend?
Indian NBFCs and fintechs face unique challenges that global credit scoring libraries don't address:
- RBI CAT/NonCAT segmentation - Regulatory requirement for different risk treatment based on income threshold (Rs 30 lakh)
- Bureau integration - CIBIL, Equifax, CRIF with consent tracking and smart caching
- CIBIL-scale scoring - 300-900 scale that Indian lenders understand
- Indian document validation - PAN, Aadhaar, GSTIN, IFSC validators
- NPA classification - SMA-0/1/2, Sub-Standard, Doubtful, Loss per RBI norms
- Alternative scoring - UPI, phone, e-commerce data for thin-file applicants (~300M credit-invisible Indians)
Features
Credit Scoring
- Multi-model ensemble (HistGBM, Random Forest, Extra Trees, Logistic Regression)
- PyTorch neural network with Apple Silicon Metal GPU acceleration
- CAT/NonCAT segment-specific models
- Probability calibration (Platt scaling)
- Alternative data scoring for thin-file applicants
Bureau Integration
- CIBIL, Equifax, CRIF bureau simulation with deterministic responses
- Consent tracking (RBI mandate)
- Smart caching and fallback ordering
- Bureau call cost optimization
Income Verification
- Priority-based: ITR > GST > Salary Slip > Bank Statement
- Tax estimation (new regime slabs)
- GST turnover analysis
- Salary consistency checking
Policy Engine
- Business Rules Engine (BRE) with eligibility knockout + approval criteria
- Risk-based dynamic pricing
- EMI calculation
- Batch evaluation
Risk Assessment
- PD/LGD/EAD/Expected Loss (Basel III IRB approach)
- Portfolio monitoring with NPL tracking
- Default prediction (6/12/24 month horizons)
- Early Warning System
- Stress testing (5 scenarios)
RBI Compliance
- NPA classification per RBI norms
- Divergence tracking (bureau vs internal)
- Fairness auditing (4/5ths rule)
- Provisioning rate calculation
Installation
pip install indialend
With optional dependencies:
# Apple Silicon Metal GPU support (neural network)
pip install indialend[gpu]
# All optional dependencies
pip install indialend[all]
Quick Start
from indialend import CreditScorer, load_sample_data
# Load sample data (1000 synthetic Indian credit applications)
X_train, X_test, y_train, y_test = load_sample_data()
# Train credit scoring model
scorer = CreditScorer()
scorer.fit(X_train, y_train)
# Score applicants (CIBIL-like 300-900 scale)
scores = scorer.score(X_test)
print(scores.head())
# default_probability cibil_score risk_grade segment
# 0 0.023145 886 A NonCAT
# 1 0.156789 806 A CAT
# 2 0.892345 365 E NonCAT
Neural Network with Metal GPU
from indialend import NeuralCreditScorer
# Train on Apple Silicon Metal GPU
neural = NeuralCreditScorer(
epochs=100,
batch_size=2048,
device="auto", # auto-detects MPS/CUDA/CPU
verbose=True,
)
neural.fit(X_train, y_train, X_val=X_test, y_val=y_test)
scores = neural.score(X_test)
Multi-Model Ensemble
from indialend import EnsembleCreditScorer
# Train 6+ models and combine with AUC-weighted averaging
ensemble = EnsembleCreditScorer(verbose=True)
ensemble.fit(X_train, y_train, X_val=X_test, y_val=y_test)
# Compare all models
comparison = ensemble.compare_models(X_test, y_test)
print(comparison)
Full Training Pipeline
# Train all models on 200K synthetic data with Metal GPU
python train_models.py
# Quick test run
python train_models.py --quick
# Large dataset with more epochs
python train_models.py --samples 500000 --epochs 200
Bureau + Income + Policy Decision
from indialend import BureauManager, IncomeVerifier, PolicyEngine
# Bureau check
bureau = BureauManager()
report = bureau.fetch("ABCDE1234F", bureau_type="CIBIL")
# Income verification
verifier = IncomeVerifier()
income = verifier.verify({"itr_income": 800000, "salary_monthly": 65000})
# Policy decision
engine = PolicyEngine()
decision = engine.evaluate({
"annual_income": 800000,
"cibil_score": 720,
"loan_amount": 500000,
"employment_type": "Salaried",
"age": 32,
})
print(decision["decision"]) # "APPROVED" / "REJECTED" / "MANUAL_REVIEW"
Synthetic Data
Generate realistic Indian credit application data:
from indialend import generate_synthetic_data
# 200K applications with 69 correlated features
df = generate_synthetic_data(n_samples=200_000)
print(f"Shape: {df.shape}")
print(f"Default rate: {df['default_flag'].mean():.2%}")
print(f"CAT segment: {(df['cat_segment'] == 'CAT').mean():.1%}")
Features include demographics, geography (4-tier cities), employment, income, bureau history, alternative data (UPI, phone, e-commerce), and realistic correlations.
Architecture
indialend/
credit_scoring.py - CreditScorer, AlternativeScorer, CAT/NonCAT
neural_scorer.py - NeuralCreditScorer (PyTorch + Metal GPU)
ensemble_scorer.py - EnsembleCreditScorer, ModelFactory
bureau_integration.py - BureauManager, ConsentTracker
income_verification.py - IncomeVerifier, ITR/GST/Salary parsers
policy_engine.py - PolicyEngine, BRE, DecisionRules
risk_assessment.py - PD/LGD/EAD, PortfolioMonitor, StressTest
compliance.py - NPA classification, fairness auditing
data_management.py - Validators, KYC, deduplication
utils.py - Synthetic data, PAN/Aadhaar validators
Hardware Requirements
- Minimum: Any machine with Python 3.9+ and 4GB RAM
- Recommended: Apple Silicon Mac (M1/M2/M3/M4) for Metal GPU acceleration
- Training 200K samples: ~16GB RAM, ~5 minutes on M4
License
MIT License. See LICENSE for details.
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 indialend-1.0.0.tar.gz.
File metadata
- Download URL: indialend-1.0.0.tar.gz
- Upload date:
- Size: 70.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
56bef72e7f0c49952642e82e3be941fe1bbe750c0367704b5baa099068d6a085
|
|
| MD5 |
2608f3f3131bcc09bad750fab324f2bf
|
|
| BLAKE2b-256 |
4bf9e8395533c8f32f477d666382cb170b6e37ada21566e73984d714ae8c2ddc
|
File details
Details for the file indialend-1.0.0-py3-none-any.whl.
File metadata
- Download URL: indialend-1.0.0-py3-none-any.whl
- Upload date:
- Size: 71.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7e13c742fab6f6c1d01a5aba6ead72eb3e89d0b698d99fc6b85b9a890450595b
|
|
| MD5 |
ad67c0458463a5c20518fdf00049fc04
|
|
| BLAKE2b-256 |
bb6f925ad004c0fd30e8de468631a641f08a2cc7f8a1863ebeb50e86414e4d2c
|