Package moa.streams

Class ImbalancedStream

  • All Implemented Interfaces:
    Configurable, Serializable, CapabilitiesHandler, MOAObject, OptionHandler, ExampleStream<Example<Instance>>, InstanceStream

    public class ImbalancedStream
    extends AbstractOptionHandler
    implements InstanceStream
    Imbalanced Stream. This is a meta-generator that produces class imbalance in a stream. Only two parameters are required to be set: - The original stream - The ratio (proportion) of each class in the stream. The second parameter determines the ratio of each class in the output stream. The ratio of each class should be provided as a real number between 0.0 and 1.0, each being followed by a semicolon, and their sum should add up to 1.0. The default value of 0.9;0.1 stands for an output stream where approximately 90% of the instances belonging to the first class while the remainder 10% would belong to the secondary class.
    Version:
    1.0
    Author:
    Jean Paul Barddal (jean.barddal@ppgia.pucpr.br)
    See Also:
    Serialized Form
    • Field Detail

      • instanceRandomSeedOption

        public IntOption instanceRandomSeedOption
      • instancesBuffer

        protected Instances[] instancesBuffer
      • probPerClass

        protected double[] probPerClass
      • random

        protected Random random
      • numClasses

        protected int numClasses
    • Constructor Detail

      • ImbalancedStream

        public ImbalancedStream()
    • Method Detail

      • prepareForUseImpl

        protected void prepareForUseImpl​(TaskMonitor monitor,
                                         ObjectRepository repository)
        Description copied from class: AbstractOptionHandler
        This method describes the implementation of how to prepare this object for use. All classes that extends this class have to implement prepareForUseImpl and not prepareForUse since prepareForUse calls prepareForUseImpl.
        Specified by:
        prepareForUseImpl in class AbstractOptionHandler
        Parameters:
        monitor - the TaskMonitor to use
        repository - the ObjectRepository to use
      • getHeader

        public InstancesHeader getHeader()
        Description copied from interface: ExampleStream
        Gets the header of this stream. This is useful to know attributes and classes. InstancesHeader is an extension of weka.Instances.
        Specified by:
        getHeader in interface ExampleStream<Example<Instance>>
        Returns:
        the header of this stream
      • estimatedRemainingInstances

        public long estimatedRemainingInstances()
        Description copied from interface: ExampleStream
        Gets the estimated number of remaining instances in this stream
        Specified by:
        estimatedRemainingInstances in interface ExampleStream<Example<Instance>>
        Returns:
        the estimated number of instances to get from this stream
      • hasMoreInstances

        public boolean hasMoreInstances()
        Description copied from interface: ExampleStream
        Gets whether this stream has more instances to output. This is useful when reading streams from files.
        Specified by:
        hasMoreInstances in interface ExampleStream<Example<Instance>>
        Returns:
        true if this stream has more instances to output
      • getDescription

        public void getDescription​(StringBuilder sb,
                                   int indent)
        Description copied from interface: MOAObject
        Returns a string representation of this object. Used in AbstractMOAObject.toString to give a string representation of the object.
        Specified by:
        getDescription in interface MOAObject
        Parameters:
        sb - the stringbuilder to add the description
        indent - the number of characters to indent