- Download LendingClub loan dataset then decompress it (1.6GB): https://www.kaggle.com/datasets/wordsforthewise/lending-club
Rename it to
lending_data.csv
-
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 30000where n_good represent non-defaulted (successful) loans and n_bad represent defaulted loans data. -
Now 2 datasets are produced in our
outdir:lendingclub_model_ready_no_file.csvandlendingclub_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.csvretains the same credit history fields, whilelendingclub_model_ready_no_file.csvhas 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)
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...
- Run
python3 Plot_Graphs/train_n_plot_roc.py, this will train a model (using Logistic Regression) with thelendingclub_model_ready_no_file.csvdata, then with thelendingclub_model_ready_traditional.csvdataset, and will compare the accuracy of both in one graph.
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 200It starts losing accuracy when trained for too long, so we made sure to stop early.
-
We now have the artifacts in
artifactsdir.
-
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, thennpm install -
Replace the src/App.jsx code with the one in here
-
You have a full interactive offline creditless score predictor and risk assessor!




