mlrl.common.cython.instance_sampling module

@author: Michael Rapp (michael.rapp.ml@gmail.com)

class mlrl.common.cython.instance_sampling.ExampleWiseStratifiedInstanceSamplingConfig

Bases: object

Allows to configure a method for selecting a subset of the available training examples using stratification, where distinct label vectors are treated as individual classes.

get_max_samples() int

Returns the maximum number of examples that are included in a sample.

Returns:

The maximum number of examples that are included in a sample

get_min_samples() int

Returns the minimum number of examples that are included in a sample.

Returns:

The minimum number of examples that are included in a sample

get_sample_size() float

Returns the fraction of examples that are included in a sample.

Returns:

The fraction of examples that are included in a sample

set_max_samples(max_samples: int) ExampleWiseStratifiedInstanceSamplingConfig

Sets the maximum number of examples that should be included in a sample.

Parameters:

max_samples – The maximum number of examples that should be included in a sample. Must be at least get_min_samples() or 0, if the number of examples should not be restricted

Returns:

An ExampleWiseStratifiedInstanceSamplingConfig that allows further configuration of the method for sampling instances

set_min_samples(min_samples: int) ExampleWiseStratifiedInstanceSamplingConfig

Sets the minimum number of examples that should be included in a sample.

Parameters:

min_samples – The minimum number of examples that should be included in a sample. Must be at least 1

Returns:

An ExampleWiseStratifiedInstanceSamplingConfig that allows further configuration of the method for sampling instances

set_sample_size(sample_size: float) ExampleWiseStratifiedInstanceSamplingConfig

Sets the fraction of examples that should be included in a sample.

Parameters:

sample_size – The fraction of examples that should be included in a sample, e.g., a value of 0.6 corresponds to 60 % of the available training examples. Must be in (0, 1)

Returns:

An ExampleWiseStratifiedInstanceSamplingConfig that allows further configuration of the method for sampling instances

class mlrl.common.cython.instance_sampling.InstanceSamplingWithReplacementConfig

Bases: object

Allows to configure a method for selecting a subset of the available training examples with replacement.

get_max_samples() int

Returns the maximum number of examples that are included in a sample.

Returns:

The maximum number of examples that are included in a sample

get_min_samples() int

Returns the minimum number of examples that are included in a sample.

Returns:

The minimum number of examples that are included in a sample

get_sample_size() float

Returns the fraction of examples that are included in a sample.

Returns:

The fraction of examples that are included in a sample

set_max_samples(max_samples: int) InstanceSamplingWithReplacementConfig

Sets the maximum number of examples that should be included in a sample.

Parameters:

max_samples – The maximum number of examples that should be included in a sample. Must be at least get_min_samples() or 0, if the number of examples should not be restricted

Returns:

An InstanceSamplingWithReplacementConfig that allows further configuration of the method for sampling instances

set_min_samples(min_samples: int) InstanceSamplingWithReplacementConfig

Sets the minimum number of examples that should be included in a sample.

Parameters:

min_samples – The minimum number of examples that should be included in a sample. Must be at least 1

Returns:

An InstanceSamplingWithReplacementConfig that allows further configuration of the method for sampling instances

set_sample_size(sample_size: float) InstanceSamplingWithReplacementConfig

Sets the fraction of examples that should be included in a sample.

Parameters:

sample_size – The fraction of examples that should be included in a sample, e.g., a value of 0.6 corresponds to 60 % of the available training examples. Must be in (0, 1)

Returns:

An InstanceSamplingWithReplacementConfig that allows further configuration of the method for sampling instances

class mlrl.common.cython.instance_sampling.InstanceSamplingWithoutReplacementConfig

Bases: object

Allows to configure a method for selecting a subset of the available training examples without replacement.

get_max_samples() int

Returns the maximum number of examples that are included in a sample.

Returns:

The maximum number of examples that are included in a sample

get_min_samples() int

Returns the minimum number of examples that are included in a sample.

Returns:

The minimum number of examples that are included in a sample

get_sample_size() float

Returns the fraction of examples that are included in a sample.

Returns:

The fraction of examples that are included in a sample

set_max_samples(max_samples: int) InstanceSamplingWithoutReplacementConfig

Sets the maximum number of examples that should be included in a sample.

Parameters:

max_samples – The maximum number of examples that should be included in a sample. Must be at least get_min_samples() or 0, if the number of examples should not be restricted

Returns:

An InstanceSamplingWithReplacementConfig that allows further configuration of the method for sampling instances

set_min_samples(min_samples: int) InstanceSamplingWithoutReplacementConfig

Sets the minimum number of examples that should be included in a sample.

Parameters:

min_samples – The minimum number of examples that should be included in a sample. Must be at least 1

Returns:

An InstanceSamplingWithReplacementConfig that allows further configuration of the method for sampling instances

set_sample_size(sample_size: float) InstanceSamplingWithoutReplacementConfig

Sets the fraction of examples that should be included in a sample.

Parameters:

sample_size – The fraction of examples that should be included in a sample, e.g., a value of 0.6 corresponds to 60 % of the available training examples. Must be in (0, 1)

Returns:

An InstanceSamplingWithoutReplacementConfig that allows further configuration of the method for sampling instances

class mlrl.common.cython.instance_sampling.OutputWiseStratifiedInstanceSamplingConfig

Bases: object

Allows to configure a method for selecting a subset of the available training examples using stratification, such that for each label the proportion of relevant and irrelevant examples is maintained.

get_max_samples() int

Returns the maximum number of examples that are included in a sample.

Returns:

The maximum number of examples that are included in a sample

get_min_samples() int

Returns the minimum number of examples that are included in a sample.

Returns:

The minimum number of examples that are included in a sample

get_sample_size() float

Returns the fraction of examples that are included in a sample.

Returns:

The fraction of examples that are included in a sample

set_max_samples(max_samples: int) OutputWiseStratifiedInstanceSamplingConfig

Sets the maximum number of examples that should be included in a sample.

Parameters:

max_samples – The maximum number of examples that should be included in a sample. Must be at least get_min_samples() or 0, if the number of examples should not be restricted

Returns:

An OutputWiseStratifiedInstanceSamplingConfig that allows further configuration of the method for sampling instances

set_min_samples(min_samples: int) OutputWiseStratifiedInstanceSamplingConfig

Sets the minimum number of examples that should be included in a sample.

Parameters:

min_samples – The minimum number of examples that should be included in a sample. Must be at least 1

Returns:

An OutputWiseStratifiedInstanceSamplingConfig that allows further configuration of the method for sampling instances

set_sample_size(sample_size: float) OutputWiseStratifiedInstanceSamplingConfig

Sets the fraction of examples that should be included in a sample.

Parameters:

sample_size – The fraction of examples that should be included in a sample, e.g., a value of 0.6 corresponds to 60 % of the available training examples. Must be in (0, 1)

Returns:

An OutputWiseStratifiedInstanceSamplingConfig that allows further configuration of the method for sampling instances