Bootstrap sampling splitters.
Classes
Bootstrap validation (.632 method).
Samples with replacement for training, out-of-bag samples for testing.
Constructor
__init__( self, n_iterations: int = 100, sample_size: float = 1.0, random_state: Optional[int] = None, )
Parameters
n_iterations
int
= 100
Number of bootstrap iterations.
sample_size
float
= 1.0
Size of bootstrap sample relative to original dataset.
random_state
int
Random seed.
Notes
On average, ~63.2% of samples appear in training set (bootstrap sample) and ~36.8% are out-of-bag (test set).
python
>>> from tuiml.evaluation.splitting import BootstrapSplit
>>> import numpy as np
>>> X = np.arange(100).reshape(-1, 1)
>>> bs = BootstrapSplit(n_iterations=10)
>>> splits = list(bs.split(X))
>>> len(splits)
10
Each training set is drawn with replacement and so always has n_samples
entries; the test set is whatever was left out, so its size varies:
python
>>> train_idx, test_idx = splits[0]
>>> len(train_idx)
100
>>> 0 < len(test_idx) < 100
True