Weighted Random Samplers

Ver. 1.0.0 (2023-04-16)

This module provides a ready-to-use stream sampler class SamplerWeightedRND, in which each instance is randomly uniformly weighted. Then, it is compared to a pre-defined threshold. If the weight of an instance is higher than the threshold, then the instance is not omitted. Otherwise, it is omitted.

class mlpro.bf.streams.samplers.weighted_random.SamplerWeightedRND(p_num_instances: int = 0, p_threshold: float = 0.5, p_seed: int = 0)

Bases: Sampler

A ready-to-use class for data streams with random sampler and weighted instance. This object can be used in Stream.

Parameters:
  • p_num_instances (int) – Number of instances. This parameter has no affect in this sampler method. Default = 0.

  • p_threshold (float) – Threshold for selection of an instance. This value must be between 0 to 1. Default = 0.5.

  • p_seed (int) – Random seeding. Default = 0.

C_TYPE = 'Weighted Random Sampler'
reset()

A method to reset the sampler’s settings.

_omit_instance(p_inst: Instance) bool

A custom method to filter any incoming instances, which is being called by omit_instance() method.

Parameters:

p_inst (Instance) – An input instance to be filtered.

Returns:

False means the input instance is not omitted, otherwise True.

Return type:

bool