Giter VIP home page Giter VIP logo

loan-default-risk-prediction's Introduction

Home Credit Loan Default Risk Prediction

Project Overview

As a lending company, it is important to know the applicants' repayment abilities so that the company can decide whether to provide a loan to those applicants or not based on their data.

  • Predict how capable each applicant is of repaying a loan based on their data such as applicant's income, credit amount of loan, loan annuity, price of the goods for which the loan is given, applicant's age, type of organization where the applicant works, etc.
  • The dataset was from Project-based Internship of Home Credit Indonesia x Rakamin, but also accessible on Kaggle here. I only used the 'application_train.csv' data for this project.
  • Deploy a Machine Learning model using Flask so the end-users can input the applicant's data and get the prediction directly. Here is the screen recording of the web app on my local page.

Objectives

  • The objective is to make a loan default risk prediction based on several applicant variables. As a result, the model can help the company to know the ability of the applicant so they can decide whether to give a loan or not.

Methodology

  • Preprocessing Data

    Checked the duplicate data, changed the data types, handled missing values (deleted columns that have >50% missing values, removed columns that only have 1 class, imputed using data mean for the numerical variables and mode for the categorical variables), did feature selection (used ANOVA and Chi-Square for selecting the correlated variables), handled categorical data (used frequency encoding to not enlarge the data dimensions), handled imbalanced data (used undersampling for majority class), and did the feature scaling for the numerical variables (used standardization).

  • Modeling and Evaluation

    The methods used were Logistic Regression and Random Forest Classifier using the F1-score of 5-fold cross-validation as an evaluation model. Also only used Random Forest features importance for the final variables.

Web App (Flask)

End-users can predict the applicants' repayment abilities based on these variables:

  • Income of the applicant
  • Credit amount of the loan
  • Loan annuity
  • Price of the goods
  • Region population relative: Normalized population of region where the applicant lives
  • Applicant's age
  • Day of applying for the loan: Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday
  • Hour of applying for the loan: 1 up to 24
  • Organization type where the applicant works: Transport, Medicine, Construction, Housing, Services, Bank, Insurance, School, Telecom, and many more
  • Number of credit bureau requests: Number of enquiries to credit bureau about the applicant one year before application (excluding last 3 months before application)
  • Days of employed: How many days before the application did the applicant start his current employment
  • Days of registration: How many days before the application did the applicant change his registration
  • Days of ID publish: How many days before the application did the applicant change the identity document with which he applied for the loan
  • Days of last phone change: How many days before the application did the applicant change his phone
  • Years of begin expluatation mode: Normalized information about the building where the applicant lives
  • Total area mode: Normalized information about the building where the applicant lives
  • External Source 2: Normalized score from external data source
  • External Source 3: Normalized score from external data source

Those variables were the result of the Random Forest features importance using 'SelectFromModel' method and the model for deployment used Logistic Regression for the lighter model.

Code for deployment can be accessed in this folder. Use this command below in the terminal to automatically install all the packages needed and run the web app

pip install -r requirements.txt

python app.py

Conclusions

The F1-score of the Logistic Regression was 65.88% and the Random Forest Classifier was 66.48%.

loan-default-risk-prediction's People

Contributors

wandalistathea avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.