NYC Data Science Academy| Blog
Bootcamps
Lifetime Job Support Available Financing Available
Bootcamps
Data Science with Machine Learning Flagship ๐Ÿ† Data Analytics Bootcamp Artificial Intelligence Bootcamp New Release ๐ŸŽ‰
Free Lesson
Intro to Data Science New Release ๐ŸŽ‰
Find Inspiration
Find Alumni with Similar Background
Job Outlook
Occupational Outlook Graduate Outcomes Must See ๐Ÿ”ฅ
Alumni
Success Stories Testimonials Alumni Directory Alumni Exclusive Study Program
Courses
View Bundled Courses
Financing Available
Bootcamp Prep Popular ๐Ÿ”ฅ Data Science Mastery Data Science Launchpad with Python View AI Courses Generative AI for Everyone New ๐ŸŽ‰ Generative AI for Finance New ๐ŸŽ‰ Generative AI for Marketing New ๐ŸŽ‰
Bundle Up
Learn More and Save More
Combination of data science courses.
View Data Science Courses
Beginner
Introductory Python
Intermediate
Data Science Python: Data Analysis and Visualization Popular ๐Ÿ”ฅ Data Science R: Data Analysis and Visualization
Advanced
Data Science Python: Machine Learning Popular ๐Ÿ”ฅ Data Science R: Machine Learning Designing and Implementing Production MLOps New ๐ŸŽ‰ Natural Language Processing for Production (NLP) New ๐ŸŽ‰
Find Inspiration
Get Course Recommendation Must Try ๐Ÿ’Ž An Ultimate Guide to Become a Data Scientist
For Companies
For Companies
Corporate Offerings Hiring Partners Candidate Portfolio Hire Our Graduates
Students Work
Students Work
All Posts Capstone Data Visualization Machine Learning Python Projects R Projects
Tutorials
About
About
About Us Accreditation Contact Us Join Us FAQ Webinars Subscription An Ultimate Guide to
Become a Data Scientist
    Login
NYC Data Science Acedemy
Bootcamps
Courses
Students Work
About
Bootcamps
Bootcamps
Data Science with Machine Learning Flagship
Data Analytics Bootcamp
Artificial Intelligence Bootcamp New Release ๐ŸŽ‰
Free Lessons
Intro to Data Science New Release ๐ŸŽ‰
Find Inspiration
Find Alumni with Similar Background
Job Outlook
Occupational Outlook
Graduate Outcomes Must See ๐Ÿ”ฅ
Alumni
Success Stories
Testimonials
Alumni Directory
Alumni Exclusive Study Program
Courses
Bundles
financing available
View All Bundles
Bootcamp Prep
Data Science Mastery
Data Science Launchpad with Python NEW!
View AI Courses
Generative AI for Everyone
Generative AI for Finance
Generative AI for Marketing
View Data Science Courses
View All Professional Development Courses
Beginner
Introductory Python
Intermediate
Python: Data Analysis and Visualization
R: Data Analysis and Visualization
Advanced
Python: Machine Learning
R: Machine Learning
Designing and Implementing Production MLOps
Natural Language Processing for Production (NLP)
For Companies
Corporate Offerings
Hiring Partners
Candidate Portfolio
Hire Our Graduates
Students Work
All Posts
Capstone
Data Visualization
Machine Learning
Python Projects
R Projects
About
Accreditation
About Us
Contact Us
Join Us
FAQ
Webinars
Subscription
An Ultimate Guide to Become a Data Scientist
Tutorials
Data Analytics
  • Learn Pandas
  • Learn NumPy
  • Learn SciPy
  • Learn Matplotlib
Machine Learning
  • Boosting
  • Random Forest
  • Linear Regression
  • Decision Tree
  • PCA
Interview by Companies
  • JPMC
  • Google
  • Facebook
Artificial Intelligence
  • Learn Generative AI
  • Learn ChatGPT-3.5
  • Learn ChatGPT-4
  • Learn Google Bard
Coding
  • Learn Python
  • Learn SQL
  • Learn MySQL
  • Learn NoSQL
  • Learn PySpark
  • Learn PyTorch
Interview Questions
  • Python Hard
  • R Easy
  • R Hard
  • SQL Easy
  • SQL Hard
  • Python Easy
Data Science Blog > Capstone > LendingClub Investments - Loan Default & Investor ROI

LendingClub Investments - Loan Default & Investor ROI

Chaitali Majumder and Thomas Kim
Posted on May 5, 2021

The skills the author demoed here can be learned through taking Data Science with Machine Learning bootcamp with NYC Data Science Academy.

Introduction to LendingClub - Pt. 1

In financial industry, banks have historically handled most consumer and small business lending to a great extent. However, banks have some key limitations like interest rates are not individualized, loan decisions can take months, regulation process is strong, and the costs of underwriting loans are high. Peer-to-peer (P2P) lending platforms offer loan opportunities outside of traditional lending institutions and it generally provides higher returns to the investors relative to other types of investments because of the lower regulatory burdens. Founded in 2007, LendingClub pioneered an online peer to peer marketplace that sought to streamline the process of obtaining a loan by directly connecting borrowers and lenders without an intermediary.

Borrowers would fill out an application detailing their credit history, loan details, employment status and other self-reported information by which LendingClub would assign a loan grade reflecting the quality of a loan. Potential investors would be able to view the details of various loan applications and make a final decision to invest in the loan. LendingClub would take a flat service fee from the transaction, and this was much preferable to traditional bank loans since banks would take part in the interest payments.

LendingClub Investments - Loan Default & Investor ROI

Introduction to LendingClub - Pt. 2

However, with any type of loan, risks of default are major concerns for the investors. Most loans that were listed on LendingClub were unsecured personal loans, meaning that there was no collateral backing up the loan. Therefore, the lender/investor would essentially lose all their money if the borrower defaulted. Such financial losses incurred by default loans are detrimental to both borrowers and especially investors, which is why a machine learning approach can be beneficial to help filter out bad loans and create a more risk-averse investment portfolios for investors.

In this project, we hope to devise a machine learning model that could reduce the cost of risk due to high-risk loans while maximizing the return on investment (ROI) for the investors. The dataset used for this project was provided by LendingClub and contains 2,260,701 observations of individual loan applications submitted between 2007-2018 with 151 quantitative/qualitative features. These features capture various information provided at the time of the loan application as well as available information after loan issuance and therefore not available to investors at the moment of investing.

Research Goals

There were 3 primary goals for this project:

  1. Accurately predict probabilities loan defaults using machine learning and deep learning approaches.
  2. Optimize for the best investment opportunity set by loan grades for investors looking to maximize ROI.
  3. Construct real-time ROI simulation interface based on loan grades to leverage ML models for investment allocation.

Key Considerations

We considered following key points before processing the data:

  • The scope of the project would be on 2.26 million approved loans only. Rejected loans are not considered for analysis.
  • The dataset is imbalanced. Paid off loans exceed default loans 6.7 to 1
  • โ€˜Currentโ€™ loans, โ€™Lateโ€™ loans and loans in โ€˜grace periodโ€™ excluded from the scope as those will not help in machine learning prediction.

Preprocessing of LendingClub Data

The first step in our data preprocessing procedure was to parse through the different features and separate information known at the time of loan origination from dynamic information that is subject to change based on loan performance, such as collection status. When building predictive machine learning models, it is important to avoid introducing features that is otherwise not known at the time of loan issuance since it might result in overly optimistic if not completely invalid predictive models due to data leakage.

After removing leaky variables from the dataset, features with more than 80% missing values were dropped and the remaining missing values were either imputed with median values for numerical variables or mode values for categorical variables.

When appropriate, features with NaN values were imputed as zeros depending on what NaN values were interpreted as most likely representing. Other variables that included unique values for each loan such as โ€˜policy_codeโ€™ or โ€˜idโ€™ were dropped while miscellaneous features such as โ€˜stateโ€™ and โ€˜zip_codeโ€™ were dropped as well to prevent overfitting the model to noise.

Exploratory Analysis of LendingClub Data - Pt. 1

Our general exploratory data analysis reveals the rise of popularity of LendingClub loans, which reached its peak in 2015 โ€“ 2016 in terms of revenue and volume, followed by a decrease from 2017 onwards due to fraud scandals that LendingClub faced.

LendingClub Investments - Loan Default & Investor ROI

By further analysis, we observed an increase in the average debt to income ratios (DTI) for borrowers from 11% in 2007 to 19% in 2018. In other words, the increase in average DTI meant that LendingClub started attracting more borrowers who could generate greater revenue but at a higher risk of defaulting. In fact, the investor returns for lower grade loans became negative as the companyโ€™s issuance volumes grew, highlighting the importance of careful loan selection by investors.

LendingClub Investments - Loan Default & Investor ROI

LendingClub grades each borrower a credit rating ranging from A to G based on his/her application, with A as the highest credit quality and G as the lowest. Interest rates are then assigned based on each loan grade and reflects the level of default risk.

LendingClub Investments - Loan Default & Investor ROI

The graph for interest rate distribution also conveys the same message that interest rate is much higher for E, F and G grade loans and counts of these loans are lesser than other grades.

LendingClub Investments - Loan Default & Investor ROI

Accordingly, the profit/loss margins increase dramatically as loan grade decreases commensurate with level of risk.

Exploratory Analysis of LendingClub Data - Pt. 2

 

This explains the value of loan diversification in which machine learning models can help optimize the ratio of safe loans to risky loans to yield higher ROI for the investors.

LendingClub loans are either divided into 36-month or 60-month installments and term length of a loan is a key driver of risk. This makes sense since longer terms leave a longer period for the borrower into financial difficulty as more interest accumulates. Furthermore, borrowers with 60-month terms tend to have a higher DTI because applicants borrowing a larger portion of their incomes are more likely to need a longer term to pay off their loans. That said, among the fully paid loans, many borrowers tend to pay back earlier than the allotted time frame to avoid paying extra interest.

This leads to unrealized profit from the investor standpoint but for the sake of simplicity, we assume an ideal scenario in which fully paid loans are paid back with interest over the entire term.

Looking at the distribution between good and bad loans shown below, this is an imbalanced classification problem since the number of good loans outweigh the number of bad loans by 6.7 to 1. 

The imbalanced nature of the dataset poses an important problem when creating machine learning models as correctly predicting the minority class (in this case default loans) is of more interest than predicting the majority class (good loans). Given that fully paid loans comprise 85% of all approved loans, a random null model (assumes every loan is a good loan) would have a minimum predictive accuracy of 85%. Therefore, it is important to note that accuracy would not be an appropriate metric when evaluating the predictive accuracy of our model.

Feature Engineering

Credit history is undoubtedly an important factor in determining loan risk since it is a direct measure of oneโ€™s credit health and reliability. Typically, a longer credit history indicates more experience using credit and thus a better credit score. The dataset includes a feature, โ€˜earliestCrlineโ€™ that reports the date the borrowerโ€™s earliest reported credit line was opened. We converted this feature into the number of years that have passed until the time of the loan application to make it more interpretable for our model.

To calculate the ROI, we added the weighted averages of term and interest rate to the final dataset. We also dummified categorical variables to evaluate the performance of logistic regression. Finally, loans that were not either โ€˜Fully Paidโ€™ or โ€˜Charged Offโ€™ were not considered since ongoing (โ€˜currentโ€™) loans would not provide any predictive value to creating the model. The target variable, โ€˜Loan Classโ€™ were then mapped to 0โ€™s (fully paid (good) loans) or 1โ€™s (charged off (bad) loans). At the end of data processing, we filtered the dataset down to 50 features from the original 151 that we started with.

Model Evaluation & Comparison - Pt. 1

The LendingClub dataset was sorted by loan issue date and then split into a train set which included loans from 2007 to 2017 and a test set that comprised of 2018 loans. We then explored seven different models including: Logistic Regression, Linear Discriminant Analysis, Gaussian Naive Bayes, Random Forest Classifier, CatBoost Classifier, XGBoost Classifier and Neural Network.

To evaluate the performance of each model, we used the ROC_AUC score to measure the tradeoff between benefit (True Positive Rate) and cost (False Positive Rate). In simpler terms, the true positive rate or recall refers to the percentage of actual defaults we are correctly classifying with our model while false positive rate refers to the percentage of good loans that are incorrectly classified as defaults. The key here is that we would like to maximize the true positive rate, but this comes at the expense of more false positives. Therefore, we would need to choose a model that picks up as many true positives as possible for each additional false positive.

Model Evaluation & Comparison - Pt. 2

On top of the ROC_AUC score, we need to consider whether to prioritize precision or recall. This is a critical part when building an appropriate model for classification problems and largely depends on the business objective. Here, precision is defined as how well our model correctly predicts the probability that a loan defaults when the model classifies a loan to default (True Positive / (True Positive + False Positive) while recall is defined as how well our model correctly classifies a default loan among the loans that actually defaulted (True Positive/ (True Positive + False Negative).

In our case, a model that prioritizes recall is much more favorable because the objective is to minimize the false negatives (predicting no default when the loan is actually default) in order to maximize the investorโ€™s ROI.

The cost matrix offers a means to differentiate the importance of Type I and Type II classification errors. Ideally in the real world, we would be working with people with financial background to establish how much profit we are willing to forgo to better predict default loans and vice versa.

A false negative in this context would cost us real money by incorrectly classifying a default loan as a good loan whereas a false positive would simply be lost opportunity costs. Therefore, it is our best interest to lower the probability threshold which would incur more false positives but reduce false negatives. However, the probability threshold largely depends on the individualโ€™s risk tolerance and business financial goals, so we leave the threshold at the default level, which is 0.5.

Model Evaluation & Comparison - Pt. 3

Lastly, one major problem of creating a model based on an imbalanced dataset is that the model is likely to overfit to the majority class (fully paid loans) and grossly underfit the minority class (charged off loans). In order to resolve this issue, we explored undersampling and oversampling techniques as well as adjusting class weights when fitting the model.

The ROC_AUC scores, recall, accuracy, ROI and cost of risk by model on the 2018 test data are summarized in the table below:

To calculate the ROI, we simply divided the net profit by the cost of investment. The net profit was calculated as follows:

(INTEREST RATE (%) EARNED * FULLY PAID LOANS ($)) * TERM (YEAR)

- (INTEREST RATE (%) PAID * TOTAL LOAN COST ($)) * TERM (YEAR)

- CHARGED OFF LOANS ($)

Among the various models, XGBoost proved to have the best performance in terms of maximizing the ROC_AUC score and the net ROI. Other models such as Random Forest and Neural Net resulted in similar scores but took significantly longer to train compared to XGBoost.

Here are the visual representation of model performances:

Based on the results, we were able to achieve 13.6% ROI with a XGBoost model, a 7% ROI increase compared to the benchmark LendingClub ROI.

 

Model Simulation for LendingClub Investors

In order to output real-time simulated ROI for LendingClub investors, we created a simple Flask app (link) that allows the user to input the number of loans to invest for each grade and visualize the expected ROI compared to the LendingClub benchmark ROI. To achieve this, we utilized a Monte Carlo simulation to randomly select 1000 loans from the entire test set and 1000 loans from our model prediction set. This process was iterated over 1000 times to ensure simulation consistency.

The result shows that the model ROI is increased than the existing benchmark ROI and that can be a significant return for the investors of the LendingClub.

Future Scope of LendingClub Investing

The above-mentioned project definitely adds more value to business of fintech industry where we could increase the investorโ€™s ROI applying machine learning models and assuring a good return to attract more investors to invest in similar types of loans. However, we realize that this project scope can be enhanced with more realistic industry specific future directions. Adjusting probability thresholds depending on different loan grades/terms will align with industry standard approach to better predict risky loans. Accordingly, we can define the cost of risks or internal rate of return more realistic for financial domain.

For Code reference, please click here

About Authors

Chaitali Majumder

Decisive, analytical-minded Data Scientist and Business Leader with a proven track record of 10+ years of work experience in Business Process Management project implementations.
View all posts by Chaitali Majumder >

Thomas Kim

Goal-oriented data scientist with 4 years of quantitative background in biomedical research with a bachelors degree in Biology and a masters degree in Bioengineering. Demonstrated success in hypothesis testing, data analysis and visualization to communicate results to technical...
View all posts by Thomas Kim >

Leave a Comment

No comments found.

View Posts by Categories

All Posts 2399 posts
AI 7 posts
AI Agent 2 posts
AI-based hotel recommendation 1 posts
AIForGood 1 posts
Alumni 60 posts
Animated Maps 1 posts
APIs 41 posts
Artificial Intelligence 2 posts
Artificial Intelligence 2 posts
AWS 13 posts
Banking 1 posts
Big Data 50 posts
Branch Analysis 1 posts
Capstone 206 posts
Career Education 7 posts
CLIP 1 posts
Community 72 posts
Congestion Zone 1 posts
Content Recommendation 1 posts
Cosine SImilarity 1 posts
Data Analysis 5 posts
Data Engineering 1 posts
Data Engineering 3 posts
Data Science 7 posts
Data Science News and Sharing 73 posts
Data Visualization 324 posts
Events 5 posts
Featured 37 posts
Function calling 1 posts
FutureTech 1 posts
Generative AI 5 posts
Hadoop 13 posts
Image Classification 1 posts
Innovation 2 posts
Kmeans Cluster 1 posts
LLM 6 posts
Machine Learning 364 posts
Marketing 1 posts
Meetup 144 posts
MLOPs 1 posts
Model Deployment 1 posts
Nagamas69 1 posts
NLP 1 posts
OpenAI 5 posts
OpenNYC Data 1 posts
pySpark 1 posts
Python 16 posts
Python 458 posts
Python data analysis 4 posts
Python Shiny 2 posts
R 404 posts
R Data Analysis 1 posts
R Shiny 560 posts
R Visualization 445 posts
RAG 1 posts
RoBERTa 1 posts
semantic rearch 2 posts
Spark 17 posts
SQL 1 posts
Streamlit 2 posts
Student Works 1687 posts
Tableau 12 posts
TensorFlow 3 posts
Traffic 1 posts
User Preference Modeling 1 posts
Vector database 2 posts
Web Scraping 483 posts
wukong138 1 posts

Our Recent Popular Posts

AI 4 AI: ChatGPT Unifies My Blog Posts
by Vinod Chugani
Dec 18, 2022
Meet Your Machine Learning Mentors: Kyle Gallatin
by Vivian Zhang
Nov 4, 2020
NICU Admissions and CCHD: Predicting Based on Data Analysis
by Paul Lee, Aron Berke, Bee Kim, Bettina Meier and Ira Villar
Jan 7, 2020

View Posts by Tags

#python #trainwithnycdsa 2019 2020 Revenue 3-points agriculture air quality airbnb airline alcohol Alex Baransky algorithm alumni Alumni Interview Alumni Reviews Alumni Spotlight alumni story Alumnus ames dataset ames housing dataset apartment rent API Application artist aws bank loans beautiful soup Best Bootcamp Best Data Science 2019 Best Data Science Bootcamp Best Data Science Bootcamp 2020 Best Ranked Big Data Book Launch Book-Signing bootcamp Bootcamp Alumni Bootcamp Prep boston safety Bundles cake recipe California Cancer Research capstone car price Career Career Day ChatGPT citibike classic cars classpass clustering Coding Course Demo Course Report covid 19 credit credit card crime frequency crops D3.js data data analysis Data Analyst data analytics data for tripadvisor reviews data science Data Science Academy Data Science Bootcamp Data science jobs Data Science Reviews Data Scientist Data Scientist Jobs data visualization database Deep Learning Demo Day Discount disney dplyr drug data e-commerce economy employee employee burnout employer networking environment feature engineering Finance Financial Data Science fitness studio Flask flight delay football gbm Get Hired ggplot2 googleVis H20 Hadoop hallmark holiday movie happiness healthcare frauds higgs boson Hiring hiring partner events Hiring Partners hotels housing housing data housing predictions housing price hy-vee Income industry Industry Experts Injuries Instructor Blog Instructor Interview insurance italki Job Job Placement Jobs Jon Krohn JP Morgan Chase Kaggle Kickstarter las vegas airport lasso regression Lead Data Scienctist Lead Data Scientist leaflet league linear regression Logistic Regression machine learning Maps market matplotlib Medical Research Meet the team meetup methal health miami beach movie music Napoli NBA netflix Networking neural network Neural networks New Courses NHL nlp NYC NYC Data Science nyc data science academy NYC Open Data nyc property NYCDSA NYCDSA Alumni Online Online Bootcamp Online Training Open Data painter pandas Part-time performance phoenix pollutants Portfolio Development precision measurement prediction Prework Programming public safety PwC python Python Data Analysis python machine learning python scrapy python web scraping python webscraping Python Workshop R R Data Analysis R language R Programming R Shiny r studio R Visualization R Workshop R-bloggers random forest Ranking recommendation recommendation system regression Remote remote data science bootcamp Scrapy scrapy visualization seaborn seafood type Selenium sentiment analysis sentiment classification Shiny Shiny Dashboard Spark Special Special Summer Sports statistics streaming Student Interview Student Showcase SVM Switchup Tableau teachers team team performance TensorFlow Testimonial tf-idf Top Data Science Bootcamp Top manufacturing companies Transfers tweets twitter videos visualization wallstreet wallstreetbets web scraping Weekend Course What to expect whiskey whiskeyadvocate wildfire word cloud word2vec XGBoost yelp youtube trending ZORI

NYC Data Science Academy

NYC Data Science Academy teaches data science, trains companies and their employees to better profit from data, excels at big data project consulting, and connects trained Data Scientists to our industry.

NYC Data Science Academy is licensed by New York State Education Department.

Get detailed curriculum information about our
amazing bootcamp!

Please enter a valid email address
Sign up completed. Thank you!

Offerings

  • HOME
  • DATA SCIENCE BOOTCAMP
  • ONLINE DATA SCIENCE BOOTCAMP
  • Professional Development Courses
  • CORPORATE OFFERINGS
  • HIRING PARTNERS
  • About

  • About Us
  • Alumni
  • Blog
  • FAQ
  • Contact Us
  • Refund Policy
  • Join Us
  • SOCIAL MEDIA

    ยฉ 2025 NYC Data Science Academy
    All rights reserved. | Site Map
    Privacy Policy | Terms of Service
    Bootcamp Application