π― Project Overview
LoanEase is a Flask-based web application designed to predict loan approval status using machine learning. The app uses a trained Gaussian NaΓ―ve Bayes model to provide instant predictions based on user-provided input, and is deployed on Railway for ease of access.
Users fill in a simple loan application form with their income, loan amount, loan term, credit history, and property area. The app validates all inputs, runs them through the pre-trained model, and returns a personalized approval or rejection result in real time.
β¨ Features
- User-friendly form β clean loan application interface with clearly labeled input fields.
- ML-powered predictions β Gaussian NaΓ―ve Bayes model predicts approval status instantly.
- Input validation β enforces rules on income, loan amount, term, and credit history before submission.
- Personalized results β displays approval or rejection messages addressed to the applicant by name.
- Graceful error handling β descriptive error pages guide users to correct invalid inputs.
- Cloud deployment β hosted on Railway for seamless, always-on access.
π οΈ Technologies Used
- Python β core programming language for the app and ML logic.
- Flask β lightweight web framework handling routing, templates, and request processing.
- Scikit-learn β Gaussian NaΓ―ve Bayes model for loan approval prediction.
- Docker & Docker Compose β containerization for consistent local and production environments.
- HTML/CSS β frontend templates and styling for all app pages.
- Railway β cloud platform for automated deployment and hosting.
πΌοΈ App Preview
Home Page β Loan Application Form
Displays the loan application form with input fields for Name, Account Number, Income, Loan Amount, Term, Credit History, and Property Area.
Prediction Page β Result Display
Shows the loan approval or rejection result with a personalized message addressed to the applicant by name and account number.
Error Page β Validation Feedback
Displays descriptive error messages for invalid inputs with a visual illustration for a better user experience.
β Input Validation Rules
- Name β cannot be empty or "0".
- Account Number β cannot be "0".
- Applicant Income β must be greater than 0.
- Loan Amount β must be greater than 0.
- Loan Term β must be at least 36 months.
- Credit History β must be a valid value (0 or 1).
π Example Workflow
Sample Input
- Name: Hasan
- Account Number: 123456
- Applicant Income: 5000
- Loan Amount: 150
- Loan Term: 360 months
- Credit History: 1 (meets guidelines)
- Property Area: Urban
Possible Outputs
- Approved: "Congratulations, Hasan! Your loan has been approved. Account Number: 123456"
- Rejected: "Unfortunately, Hasan your loan has not been approved. Account Number: 123456"
βοΈ Installation Guide
Local Setup
-
Step 1 β Clone the repository:
git clone https://github.com/msjahid/loan-approval-analysis.git -
Step 2 β Create a virtual environment:
python -m venv venvthen activate it. -
Step 3 β Install dependencies:
pip install -r requirements.txt -
Step 4 β Run the app:
python app.py -
Step 5 β Open in browser:
http://127.0.0.1:5000/
Docker Setup
-
Step 1 β Build the image:
docker-compose build -
Step 2 β Start the container:
docker-compose up -
Step 3 β Open in browser:
http://127.0.0.1:4000
Deploy on Railway
- Step 1 β Sign up or log in at railway.app.
- Step 2 β Create a new project β Deploy from GitHub repo.
- Step 3 β Railway auto-detects the Procfile and runtime.txt.
- Step 4 β Wait for the build and deployment to complete.
- Step 5 β Access your app at the Railway-provided unique URL.