Loan Approval Prediction Using KNN
This project focuses on predicting loan approval status based on customer data using a Machine Learning approach. The dataset includes various financial and personal features of applicants, and the K-Nearest Neighbors (KNN) classifier is utilized to determine whether a loan should be approved or not.
📌 Project Overview
Loan prediction is a common real-world problem faced by financial institutions. This project automates the loan eligibility process based on customer details provided in an online application form, such as Gender, Marital Status, Education, Number of Dependents, Income, Loan Amount, and Credit History.
📊 Dataset Structure
The dataset (Loan Approval Data.csv) contains 614 rows and 13 features:
Column Name Description
Loan_ID Unique Loan ID
Gender Male / Female
Married Applicant married (Y/N)
Dependents Number of dependents
Education Applicant Education (Graduate/ Under Graduate)
Self_Employed Self-employed (Y/N)
ApplicantIncome Applicant income
CoapplicantIncome Coapplicant income
LoanAmount Loan amount in thousands
Loan_Amount_Term Term of loan in months
Credit_History Credit history meets guidelines
Property_Area Urban / Semi-Urban / Rural
Loan_Status Target Variable (Y/N)
⚙️ Data Preprocessing & EDA
The project follows a standard Data Science workflow:
Exploratory Data Analysis (EDA): Checking data shape, info, summary statistics (df.describe()), and checking for missing values.
Handling Missing Values: Columns like Gender, Married, Dependents, Self_Employed, LoanAmount, Loan_Amount_Term, and Credit_History contain missing entries that require handling.
Feature Engineering & Encoding: Converting categorical variables into numerical format using LabelEncoder.
Feature Scaling: Standardizing numerical variables using StandardScaler to boost the performance of the distance-based KNN algorithm.
🤖 Model & Machine Learning
The core of the project uses the K-Nearest Neighbors (KNN) classification algorithm from scikit-learn.
Libraries Used:
Data Manipulation: pandas, numpy
Data Visualization: matplotlib, seaborn
Machine Learning: scikit-learn (Model Selection, Preprocessing, Metrics)
Evaluation Metrics:
The model is evaluated using:
Accuracy Score
Confusion Matrix
Classification Report (Precision, Recall, F1-Score)
🚀 How to Run the Project
Clone the repository:
cd your-repo-name