SampleReplicate

dabstract.abstract.abstract.SampleReplicate(data: Iterable, factor: int, lazy: bool = True, workers: int = 1, buffer_len: int = 3, *arg: List, **kwargs: Dict) → Union[dabstract.abstract.abstract.SampleReplicateAbstract, dabstract.abstract.abstract.DataAbstract, numpy.ndarray, list]

Factory function to allow for choice between lazy and direct sample replication.

For both an instance of SampleReplicateAbstract is created. Different from sample replication, is that with direct sample replication all examples are immediately evaluated.

To have more information on sample replication, please read the docstring of SampleReplicateAbstract().

dataIterable

input data to perform sample replication on

factorint

integer used to compute an index for element in data used as sample

lazybool

apply lazily or not (default = True)

workersint

amount of workers used for loading the data (default = 1)

buffer_lenint

buffer_len of the pool (default = 3)

argList

additional param to provide to the function if needed

kwargsDict

additional param to provide to the function if needed

Returns
SampleReplicateAbstract OR DataAbstract OR np.ndarray OR list
class dabstract.abstract.abstract.SampleReplicateAbstract(data: Iterable, factor: int, **kwargs: Dict)

Bases: dabstract.abstract.abstract.Abstract

Replicate data on sample-by-sample basis.

Sample replication is based on the parameter ‘factor’. This parameter is used to control to replication ratio. For example:

$ data = [1, 2, 3]
$ data_rep = SampleReplicateAbstract([1, 2, 3], factor = 3)
$ print([tmp for tmp in data_rep])
[1, 1, 1, 2, 2, 2, 3, 3, 3]

The SampleReplicateAbstract contains the following methods:

.get - return entry form SampleReplicateAbstract
.keys - return the list of keys

The full explanation for each method is provided as a docstring at each method.

dataIterable

input data to replicate on a sample-by-sample basis

factorint

integer used to compute an index for element in data used as sample

kwargsDict

additional param to provide to the function if needed

Returns
SampleReplicateAbstract class
get(index: int, return_info: bool = False, *arg: List, **kwargs: Dict) → Union[List, numpy.ndarray, Any]
Parameters
indexint

index to sample from data

return_infobool

return tuple (data, info) if True else data (default = False)

argList

additional param to provide to the function if needed

kwargsDict

additional param to provide to the function if needed

Returns
List OR np.ndarray OR Any