Stream#

class capymoa.stream.Stream[source]#

Bases: object

A datastream that can be learnt instance by instance.

__init__(
moa_stream: InstanceStream | None = None,
schema: Schema | None = None,
CLI: str | None = None,
)[source]#

Construct a Stream from a MOA stream object.

Usually, you will want to construct a Stream using the capymoa.stream.stream_from_file() function.

Parameters:
  • moa_stream – The MOA stream object to read instances from. Is None if the stream is created from a numpy array.

  • schema – The schema of the stream. If None, the schema is inferred from the moa_stream.

  • CLI – Additional command line arguments to pass to the MOA stream.

Raises:
  • ValueError – If no schema is provided and no moa_stream is provided.

  • ValueError – If command line arguments are provided without a moa_stream.

CLI_help() str[source]#

Return cli help string for 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.

get_schema() Schema[source]#

Return the schema of the stream.

get_moa_stream() InstanceStream | None[source]#

Get the MOA stream object if it exists.

restart()[source]#

Restart the stream to read instances from the beginning.