Skip to content

SamisLife/Creditless

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

44 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Instructions:

Data Wrangling:

  • We can first identify all the field names used for loan_status by running python3 read_chunk.py

  • Process a sample of the data for visualization and graphs.

    Run python3 Process_Data/process_sample.py --input lending_data.csv --outdir out --n_good 30000 --n_bad 30000 where n_good represent non-defaulted (successful) loans and n_bad represent defaulted loans data.

  • Now 2 datasets are produced in our out dir: lendingclub_model_ready_no_file.csv and lendingclub_model_ready_traditional.csv.

  • We can see that both are ready for training since data leakage fields are removed, numeric fields are cleaned, and it only retrieved completed loans with a number we chose. But the difference is that lendingclub_model_ready_traditional.csv retains the same credit history fields, while lendingclub_model_ready_no_file.csv has synthesized fields to substitute the unavailable credit history fields for newcomers. (It mathematically maps credit-based stress into everyday financial behaviors like rent, bills... It preserve risk patterns without using credit history)

Visualization:

Now that we have the data necessary for visualization, let's run the plotting scripts:

  • Run python3 Plot_Graphs/plot_eda.py, this will output 4 graphs that show the decrease or increase of the Default rate when a paramter changes, such as DTI, Utilization, Delinquencies...

Image

Image

Image

Image

  • Run python3 Plot_Graphs/train_n_plot_roc.py, this will train a model (using Logistic Regression) with the lendingclub_model_ready_no_file.csv data, then with the lendingclub_model_ready_traditional.csv dataset, and will compare the accuracy of both in one graph.

Image

Real training:

Now that we have analyzed a sample from the data, let's process the whole of the data for better results and use a more efficient algorithm.

  • Use a powerful machine or deploy an Ubuntu server from Vultr's Cloud Compute.

  • Re-download the lending_data.csv in the new machine if applicable. (You can use scp command scp lending_data.csv username@hostname:/path/to/remote/directory))

  • Run python3 Process_Data/process_full-file.py --input lending_data.csv --outdir out_full. This will output the same datasets but in full and tailored for xgboost training.

  • Now for training, run python3 train_xgb_calibrated.py --data out_full/lendingclub_model_ready_no_file_full.csv --artifacts artifacts --n_estimators 12000 --learning_rate 0.02 --max_depth 5 --early_stopping_rounds 200

    It starts losing accuracy when trained for too long, so we made sure to stop early.

  • We now have the artifacts in artifacts dir.

Productization

  • Run the API uvicorn api:app --reload

  • Now for the frontend, make a dir called frontend, and inside run: npm create vite@latest . -- --template react, then npm install

  • Replace the src/App.jsx code with the one in here

  • You have a full interactive offline creditless score predictor and risk assessor!

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors