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, dtype: str = 'float64', 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.floating]], sample_id: int, indices: ~numpy.ndarray[tuple[int, ...], ~numpy.dtype[~numpy.int32]] | 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,), dtype ``int32``, when the method resamples observations (block/IID). None for recursive methods, which have no observation-index provenance. The int32 dtype is contractual: the producer caps the series length below 2**31 observations so every index fits, and .indices() is guaranteed to return int32 (not platform intp).

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[floating]][source]

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

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

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

The returned array is int32 end to end: the engines emit int32 indices and the producer caps the series length below 2**31, so the values never overflow. Recursive methods (no observation-index provenance) return None.

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[floating]] | 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[floating]], *, axis: int = 0) ndarray[tuple[int, ...], dtype[floating]][source]

Exact quantile(s) over the n_bootstraps replicates.