Bootstrap sampling splitters.

Classes

BootstrapSplit

class evaluation.splitting.bootstrap.BootstrapSplit(BaseSplitter)

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

Methods

get_parameter_schema (cls) -> dict

Return JSON Schema for parameters.

split (self, X: np.ndarray, y: Optional[np.ndarray]=None, groups: Optional[np.ndarray]=None) -> Iterator[Tuple[np.ndarray, np.ndarray]]

Generate bootstrap split indices.

get_n_splits (self, X: Optional[np.ndarray]=None, y: Optional[np.ndarray]=None, groups: Optional[np.ndarray]=None) -> int

Get number of splits.

__repr__ (self) -> str

Return a reproducible string form of the splitter.

Returns
repr_str
str
Constructor-style representation, e.g. BootstrapSplit(n_iterations=100, sample_size=1.0).