notes

Personal notes
git clone git://git.laack.co/notes.git
Log | Files | Refs

OutOfBag.md (764B)


      1 # Out of Bag (OOB)
      2 
      3 ML D5
      4 
      5 **Definition:** Out of bag refers to samples that are not contained within a training sampling for a given predictor when using bagging/pasting.
      6 
      7 It is 37% likely that when using bagging and selecting m random samples from the training set that a given sample will be out of bag. These can be useful because these values can then be used for validation of the individual predictor.
      8 
      9 Here is an example implementation of oob scoring used on a decision tree classifier with scikit learn:
     10 
     11 ```python3
     12 
     13 # Train and then validate predictors on their out of bag samples.
     14 
     15 bag_clf = BaggingClassifier(DecisionTreeClassifier(), n_estimators=500, oob_score=True, n_jobs=-1, random_state=10)
     16 
     17 bag_clf.fit(X_train, y_train)
     18 bag_clf.oob_score_
     19 
     20 ```