Results (tsbootstrap.results)

Structured result objects returned by the public API.

A BootstrapResult is a sequence of BootstrapSample, carries a BootstrapRunMetadata provenance record, and exposes vectorised views (values(), indices()) plus out-of-bag / in-bag primitives for downstream conformal-prediction use.

class tsbootstrap.results.BootstrapRunMetadata(method: str, method_params: dict[str, object], n_bootstraps: int, n_obs: int, n_series: int, random_state_kind: str, seed_entropy: int | ~collections.abc.Sequence[int] | None, backend: str | None = None, versions: dict[str, str] = <factory>, references: tuple[str, ...] = (), warnings: tuple[str, ...] = (), failed: bool = False, failure_reason: str | None = None)[source]

Bases: object

Provenance for a bootstrap run; everything needed to reproduce or cite it.

class tsbootstrap.results.BootstrapSample(values: ~numpy.ndarray[tuple[int, ...], ~numpy.dtype[~numpy.float64]], sample_id: int, indices: ~numpy.ndarray[tuple[int, ...], ~numpy.dtype[~numpy.int64]] | None = None, metadata: dict[str, object] = <factory>)[source]

Bases: object

One bootstrap replicate.

values

The resampled/regenerated series, shape (n,) or (n, d).

Type:

ndarray

sample_id

Replicate index i (also identifies the RNG stream that produced it).

Type:

int

indices

Original-observation indices used, shape (n,), when the method resamples observations (block/IID). None for recursive methods, which have no observation-index provenance.

Type:

ndarray or None

metadata

Optional per-sample detail (e.g. block starts/lengths).

Type:

dict

class tsbootstrap.results.BootstrapResult(samples: Iterable[BootstrapSample], metadata: BootstrapRunMetadata)[source]

Bases: Sequence[BootstrapSample]

An ordered, materialised collection of bootstrap samples plus metadata.

iter_samples() Iterator[BootstrapSample][source]

Iterate over the individual BootstrapSample objects.

values() ndarray[tuple[int, ...], dtype[float64]][source]

Stack the samples into one array, shape (n_bootstraps, n[, d]).

indices() ndarray[tuple[int, ...], dtype[int64]] | None[source]

Stacked observation indices, or None if any sample lacks them (recursive).

inbag_counts() ndarray[tuple[int, ...], dtype[int64]][source]

How many times each original observation appears per replicate.

Shape (n_bootstraps, n_obs). Raises OOBUnavailableError for methods without observation-index provenance.

get_oob_mask() ndarray[tuple[int, ...], dtype[bool]][source]

Boolean out-of-bag mask (n_bootstraps, n_obs) (True = never sampled).

class tsbootstrap.results.ReducedResult(statistics: ndarray[tuple[int, ...], dtype[float64]] | None, metadata: BootstrapRunMetadata)[source]

Bases: object

Per-replicate statistics from bootstrap_reduce(), plus provenance.

statistics has shape (n_bootstraps, |theta|), the value of the per-replicate statistic for every replicate, or is None when the run failed preparation. Peak memory is O(B * |theta|), never the O(B * n * d) of the materialised paths, so very large n_bootstraps stays in RAM.

property failed: bool

Whether preparation failed (e.g. a non-stationary fit under stability_policy='skip').

property failure_reason: str | None

Human-readable reason when failed, else None.

quantile(q: float | Sequence[float] | ndarray[tuple[int, ...], dtype[float64]], *, axis: int = 0) ndarray[tuple[int, ...], dtype[float64]][source]

Exact quantile(s) over the n_bootstraps replicates.