Credit Prediction API
A simple RESTful API that predicts a user's creditworthiness (credit scoreโlike value) based on their financial data using Machine Learning.
Built with โค๏ธ using FastAPI + Scikit-Learn, this project is designed to help developers or fintech apps integrate credit prediction functionality into their systems.
๐** Features**
๐ฎ Predict creditworthiness from financial data
โก Fast and lightweight (built on FastAPI)
๐ง Machine learning model trained on sample credit data
๐งฉ Ready for integration into web or mobile apps
๐ก๏ธ Clean structure and modular code ** ๐งฐ Tech Stack**
Backend: FastAPI (Python)
ML Model: Scikit-Learn
**Data Processing: **Pandas, NumPy
Server: Uvicorn (for local hosting)
๐ Folder Structure
project-bolt/
โ
โโโ app/
โ โโโ main.py # Main API entry point
โ โโโ model.py # ML model loading and prediction logic
โ โโโ schemas.py # Request and response validation
โ โโโ utils.py # Helper functions
โ โโโ init.py
โ
โโโ model/
โ โโโ credit_model.pkl # Trained machine learning model
โ
โโโ data/
โ โโโ sample_data.csv # Example dataset
โ
โโโ requirements.txt # Dependencies
โโโ README.md # You are here ๐
โ๏ธ Installation & Setup 1๏ธโฃ Clone the repo git clone https://github.com/yourusername/credit-prediction-api.git cd credit-prediction-api
2๏ธโฃ** Create a virtual environment** python -m venv venv source venv/bin/activate # (Windows: venv\Scripts\activate)
3๏ธโฃ** Install dependencies** pip install -r requirements.txt
4๏ธโฃ** Run the API** uvicorn app.main:app --reload
Your API will be live at ๐ http://127.0.0.1:8000
๐** Endpoints** POST /predict
Description: Predict a userโs credit score range
Request Body (JSON):
{ "age": 29, "income": 45000, "loan_amount": 12000, "employment_status": "Full-Time", "credit_history": 4 }
Response (JSON):
{ "credit_score": 720, "risk_level": "Low" }
๐ง How It Works (Simplified)
User sends their financial info via POST request.
API validates data using Pydantic schemas.
The trained ML model predicts the userโs creditworthiness.
Response returns credit score + risk level.
๐** Deployment**
You can host this API easily on:
Render
Railway
Vercel (Serverless FastAPI)
AWS / GCP / Azure
๐ก** Real-World Use Cases**
๐ฆ Fintech apps checking user eligibility
๐ณ Loan approval systems
๐ฑ Credit simulation for learning/finance apps
๐งพ Data dashboards for financial risk analysis
๐งฉ Future Improvements
Connect to real user data (CIBIL-style APIs)
Add user authentication
Store prediction history in DB
Create frontend dashboard
๐ซถ** Credits**
Built by shayanna โ with the vision to make credit analysis more transparent, accessible, and AI-driven ๐