Loan Sahayak is a web application developed to predict whether a person is eligible for a loan based on user input. It uses machine learning models and follows a multi-step process involving data collection, preprocessing, model building, backend API development, and frontend development. This project is designed to assist users in determining their loan eligibility quickly and efficiently.
- Predict loan approval status (approved or denied) based on user input.
- Machine learning models (Logistic Regression, SVC, Random Forest) to predict loan eligibility.
- Backend API built with FastAPI to handle requests and interact with the machine learning model.
- Frontend built with React to collect user data and display results.
The project is divided into five main parts:
- Data Collection: Collection of the loan application dataset.
- Data Preprocessing: Cleaning and preparing the data for model training.
- Model Building: Training machine learning models to predict loan approval.
- Backend API Development: Creating an API to connect the frontend with the model.
- Frontend Development: Building the user interface to interact with the backend and display predictions.
- Machine Learning: Python, scikit-learn
- Backend: FastAPI, Python
- Frontend: React.js, JavaScript
- Model Deployment: joblib (for saving the model)
- Data Handling: pandas, numpy
- Web Framework: React.js, FastAPI
- Version Control: Git, GitHub
The dataset contains 600 rows and 13 columns, including features such as Gender, Married, Dependents, Education, ApplicantIncome, CoApplicantIncome, LoanAmount, CreditHistory, and LoanStatus. The target column is LoanStatus, indicating loan approval (1) or denial (0).
-
Handling Missing Values:
- Dropped rows with less than 5% missing values.
- Filled missing numerical values (ApplicantIncome, CoApplicantIncome) with column means.
- Filled missing categorical values (SelfEmployed) with the most frequent category.
-
Converting Categorical Data:
- Categorical variables like 'Married', 'SelfEmployed', and 'Education' were converted to numerical values using the
map()function.
- Categorical variables like 'Married', 'SelfEmployed', and 'Education' were converted to numerical values using the
-
Feature Scaling:
- Applied feature scaling to numerical columns (ApplicantIncome, CoApplicantIncome, LoanAmount, LoanAmountTerm) for model efficiency.
The data was split into features (X) and target (Y). The following models were trained and evaluated:
- Logistic Regression: 83% accuracy
- Support Vector Classifier (SVC): 82% accuracy
- Random Forest Classifier: 82% accuracy
The Logistic Regression model showed the best performance. After tuning, its accuracy improved to 85%, making it the final choice for deployment.
The trained model was saved using joblib.dump() in a .pkl file (model.pkl), which was later used for predictions in the backend.
- FastAPI is used to create the backend API.
- The API receives user input from the frontend, preprocesses it, and passes it to the trained machine learning model for prediction.
- The model predicts whether the loan will be approved (1) or denied (0), and the prediction is returned to the frontend in JSON format.
- Form Submission: The frontend collects user input (e.g., income, loan amount).
- API Request: The frontend sends the user data to the backend API.
- Prediction: The backend processes the data, runs the model, and predicts the loan status.
- Response: The prediction is sent back to the frontend in a JSON response.
The frontend is built using React.js and allows users to input their loan details into a form.
- Form Submission: Users fill out their loan details.
- API Request: The frontend sends the form data to the backend.
- Display Results: Once the backend sends the prediction, the frontend displays whether the loan is approved or denied.
You can try the live version of the application here: Live Demo
