Where averaging stops helping, which knobs matter, and how (not) to read a forest
max_features, min_samples_leaf, enough treesEach juror is right with \(p = 0.6\), independently. With three: \(0.6^3 + 3 \times 0.6^2 \times 0.4 = 0.648\).
| voters | 1 | 11 | 101 | 1,001 |
|---|---|---|---|---|
| independent (\(c = 0\)) | 0.601 | 0.755 | 0.980 | 1.000 |
| copy with prob. \(c = 0.1\) | 0.601 | 0.743 | 0.917 | 0.998 |
| copy with prob. \(c = 0.3\) | 0.601 | 0.678 | 0.618 | 0.597 |
Predict. With \(c = 0.3\), is a jury of 1,001 right more or less often than one voter alone? And with \(c = 0.1\)?
Measured: 0.0413.
max_features.| knob | values (cross-validation, CV, accuracy) | range |
|---|---|---|
n_estimators | 10: 0.941 · 100: 0.976 · 300: 0.977 | 0.036 |
max_features | 1: 0.970 · sqrt: 0.977 · None: 0.947 | 0.030 |
min_samples_leaf | 1: 0.977 · 10: 0.947 · 30: 0.915 | 0.062 |
max_depth | 3: 0.888 · 10: 0.977 · None: 0.977 | 0.089 |
criterion | gini: 0.977 · entropy: 0.979 | 0.002 |
max_features and min_samples_leaf; pick "enough trees" from the out-of-bag (OOB) curve; the rest barely matters.Predict. Which knob has the largest range? And does that mean it is worth moving?
German credit + two columns of pure noise. MDI (mean decrease in impurity): the impurity reduction each feature adds up across the trees, measured on training data.
| feature | distinct values | MDI rank | permutation rank |
|---|---|---|---|
| credit_amount | 921 | 1 | 8 |
| random_id (noise) | 1,000 | 2 | 14 |
| checking_status | 4 | 5 | 1 |
| coin (noise) | 2 | 17 | 22 |
| MDI | permutation | |
|---|---|---|
| checking_status, alone | 0.086 | 0.144 |
| checking_status, with a twin | 0.057 | 0.049 |
| checking_copy | 0.059 | 0.054 |
Predict. Where does the serial number (noise) rank under each measure? What happens to checking_status when it gets a copy?
Random thresholds instead of searched ones; no bootstrap. On digits: 0.981 against the forest's 0.977 (a tie), with twice the nodes per tree.
Trained on \(y = 3x\), \(0 \le x \le 10\): it predicts 29.6 at \(x = 12\) and at \(x = 20\). The linear model: 59.7 (truth: 60).
No bootstrap; feature and threshold drawn. Predict. Will a random threshold land near the best split, bill ≤ 82.5?
| digits | accuracy | nodes | saved size |
|---|---|---|---|
| one tree | 0.829 | 293 | 0.04 MB |
| forest, 300 trees | 0.977 | 98,696 | 14.32 MB |
| forest, leaves ≥ 3 | 0.971 | 65,754 | 9.57 MB |
X_train, y_train, cv, folds and roc_auc_score.max_features and min_samples_leaf; a threshold that sends at most 1% of legitimate e-mail to spam, chosen out-of-bag; the test, once; where the forest looks.Pace: step 8 and the first simulation in 10 min; steps 9 and 10 in 10 min; step 11 and the second in 10 min.