probly.representation.sampling.common_sample¶
Classes representing prediction samples.
Functions
|
Get the first dispatchable sample from an iterable of samples. |
Classes
|
A sample of predictions stored in a list. |
|
Abstract base class for samples. |
|
Protocol for the creation of samples. |
Default parameters for sample creation. |
- class probly.representation.sampling.common_sample.ListSample(iterable=(), /)[source]¶
Bases:
list[T],Sample,GenericA sample of predictions stored in a list.
- classmethod from_iterable(samples, sample_axis='auto')[source]¶
Create a ListSample from a sequence of samples.
- Parameters:
samples (Iterable[T]) – The predictions to create the sample from.
sample_axis (SampleAxis) – The axis along which samples are organized.
- Returns:
The created ListSample.
- Return type:
Self
- classmethod from_sample(sample, **kwargs)¶
Create a new Sample from an existing Sample.
- Parameters:
sample (Sample[T]) – The sample to create the new sample from.
kwargs (Unpack[SampleParams]) – Parameters for sample creation.
- Returns:
The created Sample.
- Return type:
Self
- append(object, /)¶
Append object to the end of the list.
- clear()¶
Remove all items from list.
- concat(other)[source]¶
Creates a new sample by concatenating another sample to this sample.
- Parameters:
other (Sample[T])
- Return type:
Self
- copy()¶
Return a shallow copy of the list.
- count(value, /)¶
Return number of occurrences of value.
- extend(iterable, /)¶
Extend list by appending elements from the iterable.
- index(value, start=0, stop=9223372036854775807, /)¶
Return first index of value.
Raises ValueError if the value is not present.
- insert(index, object, /)¶
Insert object before index.
- pop(index=-1, /)¶
Remove and return item at index (default last).
Raises IndexError if list is empty or index is out of range.
- remove(value, /)¶
Remove first occurrence of value.
Raises ValueError if the value is not present.
- reverse()¶
Reverse IN PLACE.
- sample_mean()¶
Compute the mean of the sample.
- Return type:
T
- sample_std(ddof=1)¶
Compute the standard deviation of the sample.
- Parameters:
ddof (int)
- Return type:
T
- sort(*, key=None, reverse=False)¶
Sort the list in ascending order and return None.
The sort is in-place (i.e. the list itself is modified) and stable (i.e. the order of two equal elements is maintained).
If a key function is given, apply it once to each list item and sort them, ascending or descending, according to their function values.
The reverse flag can be set to sort in descending order.
- property samples: Sequence[T]¶
Return an iterator over the samples.
- class probly.representation.sampling.common_sample.Sample[source]¶
-
Abstract base class for samples.
- abstractmethod classmethod from_iterable(samples, **kwargs)[source]¶
Create an Sample from an iterable of samples.
- Parameters:
samples (Iterable[T]) – The predictions to create the sample from.
kwargs (Unpack[SampleParams]) – Parameters for sample creation.
- Returns:
The created ArraySample.
- Return type:
Self
- classmethod from_sample(sample, **kwargs)[source]¶
Create a new Sample from an existing Sample.
- Parameters:
sample (Sample[T]) – The sample to create the new sample from.
kwargs (Unpack[SampleParams]) – Parameters for sample creation.
- Returns:
The created Sample.
- Return type:
Self
- concat(other)[source]¶
Append another sample to this sample.
- Parameters:
other (Sample[T])
- Return type:
Self
- sample_std(ddof=1)[source]¶
Compute the standard deviation of the sample.
- Parameters:
ddof (int)
- Return type:
T
- sample_var(ddof=1)[source]¶
Compute the variance of the sample.
- Parameters:
ddof (int)
- Return type:
T
- abstract property samples: Iterable[T]¶
Return an iterator over the samples.
- class probly.representation.sampling.common_sample.SampleFactory(*args, **kwargs)[source]¶
-
Protocol for the creation of samples.
- __call__(samples, **kwargs)[source]¶
Create a sample from the given predictions.
- Parameters:
samples (Iterable[T]) – The predictions to create the sample from.
kwargs (Unpack[SampleParams]) – Parameters for sample creation.
- Returns:
The created sample.
- Return type:
S
- class probly.representation.sampling.common_sample.SampleParams[source]¶
Bases:
TypedDictDefault parameters for sample creation.
- clear() None. Remove all items from D.¶
- copy() a shallow copy of D¶
- classmethod fromkeys(iterable, value=None, /)¶
Create a new dictionary with keys from iterable and values set to value.
- get(key, default=None, /)¶
Return the value for key if key is in the dictionary, else default.
- items() a set-like object providing a view on D's items¶
- keys() a set-like object providing a view on D's keys¶
- pop(k[, d]) v, remove specified key and return the corresponding value.¶
If the key is not found, return the default if given; otherwise, raise a KeyError.
- popitem()¶
Remove and return a (key, value) pair as a 2-tuple.
Pairs are returned in LIFO (last-in, first-out) order. Raises KeyError if the dict is empty.
- setdefault(key, default=None, /)¶
Insert key with a value of default if key is not in the dictionary.
Return the value for key if key is in the dictionary, else default.
- update([E, ]**F) None. Update D from dict/iterable E and F.¶
If E is present and has a .keys() method, then does: for k in E: D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]
- values() an object providing a view on D's values¶
- sample_axis: SampleAxis¶
- probly.representation.sampling.common_sample.first_dispatchable_sample(samples, **_kwargs)[source]¶
Get the first dispatchable sample from an iterable of samples.
- Parameters:
samples (Iterable) – The predictions to create the sample from.
kwargs – Parameters for sample creation.
_kwargs (Unpack[SampleParams])
- Returns:
The first dispatchable sample.
- Return type:
Any