sb_bagging
Concept Overview
Section titled “Concept Overview”Bagging in which the resampling respects label overlap. The standard bootstrap assumes IID draws; with triple-barrier labels whose spans overlap, an IID bag is full of near-duplicates, the base learners end up correlated, and the variance reduction bagging promises never materialises. Sequential bootstrap instead draws each index with probability proportional to its average uniqueness given what has already been drawn, so each bag is as close to independent as the data permits.
When to Use
Section titled “When to Use”Use it in place of ordinary bagging whenever the labels come from labeling — that is, whenever observations overlap in time. Measure the benefit rather than assuming it: ensemble_methods::average_pairwise_prediction_correlation will tell you whether the base learners actually decorrelated, and if rho is still high the extra sampling cost bought nothing. Note that new() takes the random seed, not the ensemble size: n_estimators defaults to 10 and must be set explicitly.
Mathematical Foundations
Section titled “Mathematical Foundations”Bagging Predictor
Section titled “Bagging Predictor”
where = n_estimators and is the base learner fitted to the -th resample. Note that defaults to , not to the constructor argument, which is the random seed.
Sequential Bootstrap Draw
Section titled “Sequential Bootstrap Draw”
where is the set of indices drawn so far, the bars spanned by observation ‘s label, and the number of already-drawn observations whose label also covers bar . Drawing an observation that overlaps what is already in the bag drives down, so the next draw prefers something disjoint — this is what stops the standard IID bootstrap from silently resampling the same overlapping event times. Probabilities are recomputed after every draw. See sampling for the uniqueness machinery.
Usage Examples
Section titled “Usage Examples”Instantiate SB bagging classifier
Section titled “Instantiate SB bagging classifier”use openquant::sb_bagging::SequentiallyBootstrappedBaggingClassifier;
// The single constructor argument is `random_state` — NOT the ensemble size.// n_estimators defaults to 10 and has to be set explicitly.let mut bag = SequentiallyBootstrappedBaggingClassifier::new(42);bag.n_estimators = 100;bag.oob_score = true;
println!("{} estimators, seed {}", bag.n_estimators, bag.random_state);API Reference
Section titled “API Reference”Python API
Section titled “Python API”sb_bagging.fit_predict_sb_classifiersb_bagging.fit_predict_sb_regressor
Rust API
Section titled “Rust API”SequentiallyBootstrappedBaggingClassifierSequentiallyBootstrappedBaggingRegressorMaxSamplesMaxFeatures
Risk Notes and Caveats
Section titled “Risk Notes and Caveats”- Sequential bootstrap improves diversity under event overlap.
- Tune max_samples/max_features with out-of-sample monitoring.