Difference between revisions of "Random Forest"
| Line 5: | Line 5: | ||
:: <math>\widehat{\text{Err}}_\text{boot} \dfrac{1}{B}\dfrac{1}{N}\sum^B_{b=1}\sum^N_{i=1}L(y_i, \hat{f}^{*b}(x_i)) </math> | :: <math>\widehat{\text{Err}}_\text{boot} \dfrac{1}{B}\dfrac{1}{N}\sum^B_{b=1}\sum^N_{i=1}L(y_i, \hat{f}^{*b}(x_i)) </math> | ||
However, this expression will be zero unless the ith observation does ''not'' appear in the bootstrap sample <math>b</math> | However, this expression will be zero unless the ith observation does ''not'' appear in the bootstrap sample <math>b</math> | ||
| − | :: <math>\text{Pr\{observation i | + | :: <math>\text{Pr\{observation} i \in \text{ bootstrap sample} b\} = 1 - \left(1-\dfrac{1}{N} \right)^N \approx 1-e^{-1} = 0.632 </math> |
* This is a problem because the baseline expectation is about 0.184 (0.5 x 0.368), well short of 0.5. | * This is a problem because the baseline expectation is about 0.184 (0.5 x 0.368), well short of 0.5. | ||
* The ''leave-one-out'' bootstrap mimics cross-validation in that it only uses a prediction not containing the actual observation. This solves the overfitting problem but retains the train-set-size bias present in cross-validation. | * The ''leave-one-out'' bootstrap mimics cross-validation in that it only uses a prediction not containing the actual observation. This solves the overfitting problem but retains the train-set-size bias present in cross-validation. | ||
* The '''parametric''' bootstrap | * The '''parametric''' bootstrap | ||
| − | |||
===Sklearn parameters=== | ===Sklearn parameters=== | ||
Revision as of 21:59, 8 March 2021
Random Forests reduce the variance of a Decision Tree or other CART (Classification And Regression Trees) model by averaging together multiple estimates from individual Decision Trees. Trees are trained on a random subset of features and data cases. (Microsoft's Kinect body motion detector used a Random Forest.) Trees are often "bagged" (bootstrap aggregated). In a bootstrap, samples are drawn at random with replacement to produce more training data than exist.
The Bootstrap
The bootstrap is "a simple Monte Carlo technique to approximate the sampling distribution" (Murphy, p.192), especially useful when the estimator is a complex function of the parameters. The estimate is (Hastie et al., p.250):
- [math]\displaystyle{ \widehat{\text{Err}}_\text{boot} \dfrac{1}{B}\dfrac{1}{N}\sum^B_{b=1}\sum^N_{i=1}L(y_i, \hat{f}^{*b}(x_i)) }[/math]
However, this expression will be zero unless the ith observation does not appear in the bootstrap sample [math]\displaystyle{ b }[/math]
- [math]\displaystyle{ \text{Pr\{observation} i \in \text{ bootstrap sample} b\} = 1 - \left(1-\dfrac{1}{N} \right)^N \approx 1-e^{-1} = 0.632 }[/math]
- This is a problem because the baseline expectation is about 0.184 (0.5 x 0.368), well short of 0.5.
- The leave-one-out bootstrap mimics cross-validation in that it only uses a prediction not containing the actual observation. This solves the overfitting problem but retains the train-set-size bias present in cross-validation.
- The parametric bootstrap
Sklearn parameters
n_estimators=100 criterion='gini' max_depth=None min_samples_split=2 min_samples_leaf=1 min_weight_fraction_leaf=0.0 max_features='auto' max_leaf_nodes=None min_impurity_decrease=0.0 min_impurity_split=None bootstrap=True oob_score=False class_weight=None