probly.representation.sampling.array_sample

Numpy-based sample representation.

Classes

ArraySample(array, sample_axis)

A sample of predictions stored in a numpy array.

class probly.representation.sampling.array_sample.ArraySample(array, sample_axis)[source]

Bases: Sample, NDArrayOperatorsMixin, Generic

A sample of predictions stored in a numpy array.

Parameters:
  • array (NDArray)

  • sample_axis (int)

classmethod from_iterable(samples, sample_axis='auto', dtype=None)[source]

Create an ArraySample from a sequence of samples.

Parameters:
  • samples (Iterable[D]) – The predictions to create the sample from.

  • sample_axis (SampleAxis) – The dimension along which samples are organized.

  • dtype (DTypeLike) – Desired data type of the array.

Returns:

The created ArraySample.

Return type:

Self

classmethod from_sample(sample, sample_axis='auto', dtype=None)[source]
Parameters:
  • sample (Sample[D])

  • sample_axis (SampleAxis)

  • dtype (DTypeLike)

Return type:

Self

concat(other)[source]
Parameters:

other (Sample[D])

Return type:

Self

copy()[source]

Create a copy of the ArraySample.

Returns:

A copy of the ArraySample.

Return type:

Self

move_sample_axis(new_sample_axis)[source]

Return a new ArraySample with the sample dimension moved to new_sample_axis.

Parameters:

new_sample_axis (int) – The new sample dimension.

Returns:

A new ArraySample with the sample dimension moved.

Return type:

ArraySample[D]

sample_mean()[source]

Compute the mean of the sample.

Return type:

D

sample_std(ddof=1)[source]

Compute the standard deviation of the sample.

Parameters:

ddof (int)

Return type:

D

sample_var(ddof=1)[source]

Compute the variance of the sample.

Parameters:

ddof (int)

Return type:

D

to_device(device)[source]

Move the underlying array to the specified device.

Parameters:

device (Literal['cpu']) – The target device.

Returns:

A new ArraySample on the specified device.

Return type:

Self

transpose(*axes)[source]

Return a transposed version of the ArraySample.

This method implicitly also provides full axis tracking support for - np.moveaxis - np.rollaxis Those functions call out to transpose methods for custom array types.

Parameters:

axes (int | None) – The axes to transpose.

Returns:

A transposed version of the ArraySample.

Return type:

Self

property T: Self

The transposed version of the underlying array.

array: NDArray
property device: str

The device of the underlying array.

property dtype: DTypeLike

The data type of the underlying array.

property mT: Self

The transposed version of the underlying array.

property ndim: int

The number of dimensions of the underlying array.

sample_axis: int
property sample_size: int

Return the number of samples.

property samples: ndarray

Return an iterator over the samples.

property shape: tuple[int, ...]

The shape of the underlying array.

property size: int

The total number of elements in the underlying array.