Project 02 · Classification
A decision tree on a 61-row loan sample
A small classification exercise that produced a high holdout score—and a clear lesson about sample size and model validation.
Download notebook ↓ · All projects
Data: loan.csv · 61 records · 8 original fields
Period: Course project
Tools: Python, pandas, scikit-learn, Seaborn, Matplotlib
Question
Can applicant attributes help a decision tree distinguish the recorded approved and denied loan outcomes?
Approach
I one-hot encoded the non-target columns, split the 61 rows 50/50, fit a default DecisionTreeClassifier, and reviewed accuracy, a classification report, and a confusion matrix.
Inspect the sample
The notebook checks fields, types, missingness, and outcome counts before preparing model inputs.
Encode and split
Categorical and numeric columns are one-hot encoded. A single 50/50 train-test split leaves only 31 records for evaluation.
Evaluate the errors
Accuracy is paired with class-level precision and recall and a confusion matrix, which is more informative than a score alone.
Findings and limitations
Observed finding
The saved run scored 30 of 31 test records correctly (96.8%). The confusion matrix shows 19 approved records classified correctly, one approved record misclassified, and all 11 denied records classified correctly in that split.
What to keep in mind
This is not evidence of real-world lending performance. The dataset is tiny, one-hot encoding expands it to 147 features, and the split has no fixed random seed. The result can change substantially with a different split; fairness, calibration, and external validation were not assessed.
Next iteration: For a stronger study, I would use stratified cross-validation, prune or regularize the tree, compare simple baselines, and test error rates across relevant groups. This model should never be used to make actual credit decisions.
Selected figures



Notebook and source data
The notebook preserves the analysis code with saved outputs removed and data paths normalized to a local data folder. Dataset files are not bundled; consult the notebook README and obtain appropriately licensed source data before running it.
- loan.csv (61 rows; source described on the original project page as Kaggle)