AgrawalGenerator#

class capymoa.stream.generator.AgrawalGenerator[source]#

Bases: Stream

An Agrawal Generator

>>> from capymoa.stream.generator import AgrawalGenerator
...
>>> stream = AgrawalGenerator()
>>> stream.next_instance()
LabeledInstance(
    Schema(generators.AgrawalGenerator ),
    x=ndarray(..., 9),
    y_index=1,
    y_label='groupB'
)
>>> stream.next_instance().x
array([1.40893779e+05, 0.00000000e+00, 4.40000000e+01, 4.00000000e+00,
       1.90000000e+01, 7.00000000e+00, 1.35000000e+05, 2.00000000e+00,
       3.95015339e+05])
__init__(
instance_random_seed: int = 1,
classification_function: int = 1,
peturbation: float = 0.05,
balance_classes: bool = False,
)[source]#

Construct an Agrawal Generator

Parameters:
  • instance_random_seed – Seed for random generation of instances.

  • classification_function – Classification function used, as defined in the original paper.

  • peturbation – The amount of peturbation (noise) introduced to numeric values

  • balance – Balance the number of instances of each class.

CLI_help() str[source]#

Return cli help string for the stream.

get_moa_stream() InstanceStream | None[source]#

Get the MOA stream object if it exists.

get_schema() Schema[source]#

Return the schema of the stream.

has_more_instances() bool[source]#

Return True if the stream have more instances to read.

next_instance() LabeledInstance | RegressionInstance[source]#

Return the next instance in the stream.

Raises:

ValueError – If the machine learning task is neither a regression nor a classification task.

Returns:

A labeled instances or a regression depending on the schema.

restart()[source]#

Restart the stream to read instances from the beginning.