alien.sample_generation

Submodules

alien.sample_generation.filter_generator module

class alien.sample_generation.filter_generator.Filter(source, function, threshold=0)[source]

Bases: WrappedGenerator

Filters an existing sample generator

Passes through a sample, x, if function(x) > threshold

generate_samples(N: int | float)[source]

Generates and returns N samples.

Parameters:

N – usually an integer. Different generators will interpret N == inf in different ways. It will typically return “all” samples, perhaps as an iterable.

generate_sample()

Generates and returns a single sample

alien.sample_generation.from_set module

class alien.sample_generation.from_set.SetSampleGenerator(data, shuffle: bool = True, random_seed=None, cap_to_size: bool = True, Xy: bool = False)[source]

Bases: SampleGenerator

Takes samples from a given dataset. Can remove samples upon request (eg., if they are ultimately used).

Parameters:
  • data – dataset which implements __getitem__ (with advanced slicing), __len__, and find

  • Xy – True if dataset contains both X and y values. Samples will return from self.data[:,:-1]

reshuffle()[source]

Reshuffles current indices

property labels
generate_samples(N=inf, reshuffle=False)[source]

Generates and returns N samples.

Parameters:

N – usually an integer. Different generators will interpret N == inf in different ways. It will typically return “all” samples, perhaps as an iterable.

remove_samples(samples)[source]

‘Removes’ or, rather, hides samples from this generator. Hidden samples are still stored in self.data, but will not appear in any future calls to generate_samples.

remove_sample(sample)[source]

Single-sample version of remove_samples

remove_data_indices(indices)[source]

Remove data indices and shift self.pointer accordingly

generate_sample()

Generates and returns a single sample

class alien.sample_generation.from_set.WrappedGenerator(source, random_seed=None)[source]

Bases: SampleGenerator

Generator wrapper class.

generate_samples(N)[source]

Generates and returns N samples.

Parameters:

N – usually an integer. Different generators will interpret N == inf in different ways. It will typically return “all” samples, perhaps as an iterable.

generate_sample()

Generates and returns a single sample

alien.sample_generation.generator module

class alien.sample_generation.generator.SampleGenerator[source]

Bases: object

abstract generate_samples(N)[source]

Generates and returns N samples.

Parameters:

N – usually an integer. Different generators will interpret N == inf in different ways. It will typically return “all” samples, perhaps as an iterable.

generate_sample()[source]

Generates and returns a single sample

alien.sample_generation.random_generator module

class alien.sample_generation.random_generator.UniformSampleGenerator(low=0, high=1, dtype=<class 'float'>, random_seed=None)[source]

Bases: SampleGenerator

Generates uniformly random samples

Parameters:
  • high (low,) – Samples will be returned in the range(s) [low, high) (exclusive at the upper end). The remaining dimensions (of low or high) determine the shapes of the returned samples.

  • dtype – the dtype of the returned values. Can be anything Numpy recognizes as a dtype.

  • random_seed – a random seed to initialize the RNG.

generate_samples(N)[source]

Generates and returns N samples.

Parameters:

N – usually an integer. Different generators will interpret N == inf in different ways. It will typically return “all” samples, perhaps as an iterable.

generate_sample()

Generates and returns a single sample

class alien.sample_generation.random_generator.RandomSampleGenerator(distribution='normal', *args, shape=(), dtype=<class 'float'>, random_seed=None, **kwargs)[source]

Bases: SampleGenerator

Parameters:
  • distribution

    a string indicating the type of distribution to sample from. Must be the name of one of the distributions of numpy.random.Generator. See

    https://numpy.org/doc/stable/reference/random/generator.html#distributions

  • **kwargs (*args,) –

    arguments passed to the distribution during sample generation. Typically, these parametrize the distribution. (See the reference provided above.)

    We allow args (and kwargs) to be arrays, so that each corresponding term in the sample can be sampled with different parameters. (Note that numpy distributions don’t normally allow this.)

If the shape of each of the args is var_shape, then the shape of a single sample will be

var_shape × shape

with the latter dimension repeating the parameters given in the earlier dimensions.

Parameters:

shape – as explained above, the shape of the latter dimensions of a sample, with repeated parameters.

generate_sample()

Generates and returns a single sample

generate_samples(N)[source]

Generates and returns N samples.

Parameters:

N – usually an integer. Different generators will interpret N == inf in different ways. It will typically return “all” samples, perhaps as an iterable.

alien.sample_generation.transformation module

class alien.sample_generation.transformation.TransformedSampleGenerator(source, function)[source]

Bases: WrappedGenerator

Wraps another sample generator. If the wrapped generator yields a sample x, then this generator yields sample function(x).

function may be a numpy vectorized function, or any python function. It will be vectorized if it raises a TypeError on the first call.

generate_samples(N, verbose=True)[source]

Generates and returns N samples.

Parameters:

N – usually an integer. Different generators will interpret N == inf in different ways. It will typically return “all” samples, perhaps as an iterable.

generate_sample()

Generates and returns a single sample

Module contents