aaka8566/creditScoring
0
๐ฆ NBFC AI Credit Scoring System

An advanced AI-powered credit scoring API designed for Non-Banking Financial Companies (NBFCs) with bank statement verification capabilities.
๐ Features
- Hybrid AI Scoring: XGBoost + Rule-based scoring for accurate risk assessment
- Bank Statement Processing: OCR-based extraction and verification (PDF/Image support)
- Fraud Detection: Real-time red flag analysis
- Alternative Data Integration: Beyond traditional credit scores
- Batch Processing: Score multiple applications simultaneously
- REST API: FastAPI-powered endpoints with automatic documentation
๐ API Endpoints
1. Basic Credit Scoring
POST /scoreScore a loan application using traditional credit data.
2. Bank Statement Verification
POST /score/with-statementEnhanced scoring with bank statement upload and verification.
3. Batch Processing
POST /score/batchProcess multiple loan applications at once.
4. Health Check
GET /health๐ Interactive Documentation
Once deployed, visit:
- Swagger UI:
https://YOUR_SPACE_URL/docs - ReDoc:
https://YOUR_SPACE_URL/redoc
๐ Example Usage
Simple Scoring Request
curl -X POST "https://YOUR_SPACE_URL/score" \
-H "Content-Type: application/json" \
-d '{
"age": 30,
"income": 50000,
"loan_amount": 500000,
"employment_type": "Salaried",
"credit_score": 720,
"existing_debt": 100000
}'Bank Statement Scoring
curl -X POST "https://YOUR_SPACE_URL/score/with-statement" \
-F "bank_statement=@statement.pdf" \
-F "age=30" \
-F "income=50000" \
-F "loan_amount=500000" \
-F "employment_type=Salaried" \
-F "credit_score=720" \
-F "existing_debt=100000"๐ ๏ธ Technology Stack
- Framework: FastAPI
- ML Models: XGBoost, Scikit-learn
- OCR: EasyOCR
- Document Processing: PyPDF2, OpenCV
- Deployment: Docker on Hugging Face Spaces
๐ Response Format
{
"enhanced_score": 45.5,
"risk": "Medium Risk",
"decision": "Review",
"reasons": [
"High DTI ratio (60%)",
"Good credit score"
],
"recommendations": [
"Request additional income verification",
"Consider shorter tenure"
],
"statement_verification": {
"verified": true,
"verified_income": 48500,
"income_match": true,
"red_flags": []
}
}โ๏ธ Model Information
The system uses a hybrid approach:
- XGBoost Model: ML-based risk prediction
- Rule-based System: Business logic and compliance checks
- Alternative Data: Banking behavior, transaction patterns
- Fraud Detection: Red flag analysis from bank statements
๐ Privacy & Security
- No data is stored permanently
- All processing happens in-memory
- GDPR and data privacy compliant
- Secure file handling for bank statements
๐ Documentation
For detailed API documentation and examples, see:
API_USAGE_EXAMPLES.mdBANK_STATEMENT_GUIDE.md- Interactive API docs at
/docs
๐ค Use Cases
- NBFC Loan Origination: Automated credit assessment
- Microfinance: Quick decisions for small loans
- Digital Lending Platforms: API integration
- Financial Inclusion: Alternative data for thin-file customers
๐ Performance
- Average scoring time: < 2 seconds
- Bank statement processing: < 10 seconds
- Support for PDF and image formats
- Batch processing available
๐ Known Limitations
- Ollama AI explanations not available on HF Spaces (cloud limitation)
- Large PDF files (>10MB) may take longer to process
- OCR accuracy depends on statement quality
๐ License
This project is for demonstration and educational purposes.
๐ Links
Built with โค๏ธ using FastAPI and deployed on ๐ค Hugging Face Spaces
