Brief
When a bank says no, the applicant deserves a reason. Many models can't give one, but a decision tree can: it is a list of questions, and the path an applicant takes is the explanation. In this project you grow a tree from scratch, check it against scikit-learn, and print its logic as plain if-then rules.
The data is the Statlog (German Credit Data) dataset from the UCI Machine Learning Repository. It has 1,000 past loan applicants with 20 attributes, such as checking account status, loan duration, credit history and purpose, and a label of good or bad credit risk. 700 are good and 300 are bad. The raw file uses codes like A11 for categories, so read the dataset description to name them.
A tree is built greedily. At each node you try every feature and every threshold, and keep the split that makes the two children purest. Purity is measured with Gini impurity, where is the share of class in the node:
A split into left and right children is scored by the weighted impurity , and the best split has the lowest score. Then you repeat on each child until you hit a depth limit or the node is pure. This is the CART method from Breiman and colleagues, and it is also what sklearn's DecisionTreeClassifier does.
DATA · a public credit dataset
Objectives
Read-only. Log in to update progress.
VICTORY CONDITIONS
- At every depth from 1 to 8, your test accuracy is within 1% of sklearn DecisionTreeClassifier on the same split. Record your accuracy at your chosen depth with `python tools/mlarena.py record BL-05 "<your accuracy>"`.
- The rule printout for a depth-3 tree reads as plain English and agrees with export_text on the same data.
- The README says which depth you would ship and why, using the train and test accuracy curves.
Side quests
Terms in plain words
- Decision tree
- A model that asks a chain of yes/no questions about the features and gives the answer stored at the leaf it ends up in.
- Gini impurity
- The chance that two applicants drawn at random from a node have different labels. 0 means the node is pure.
- Split
- One question of the form "is feature j at most t?", which sends each row to the left or right child.
- CART
- Classification and Regression Trees, the greedy recipe of picking the best split, recursing on each side, and stopping at a depth or size limit.
- Overfitting
- A deep tree can memorise the training rows and do worse on new ones. Limiting depth is the simplest cure.