Concept#

class capymoa.stream.drift.Concept[source]#

Bases: object

A concept and the number of instances it contributes to the stream.

Used by the range form of DriftStream, which specifies how long each concept lasts instead of where each drift lands:

>>> from capymoa.stream.drift import Concept, DriftStream, AbruptDrift
>>> from capymoa.stream.generator import SEA
>>> stream = DriftStream(stream=[
...     Concept(SEA(function=1), num_instances=1000),
...     AbruptDrift(),
...     Concept(SEA(function=3), num_instances=500),
... ])
>>> print(stream.get_drifts()[0])
AbruptDrift(position=1000)

The wrapper exists because Stream has no notion of a length: MOA generators are unbounded, and giving every stream a length to serve this one API would not survive contact with them.

Note

num_instances places the drifts; it does not ration instances. Around an AbruptDrift it is exact, because the switch is a step. Around a GradualDrift the two concepts overlap, so both contribute while the transition runs, and with the default sigmoid the older concept keeps appearing – with diminishing probability – past the nominal end of the window. A concept declared as 500 instances may therefore be drawn from rather more often than 500 times. See GradualDrift for the shape of the ramp.

__init__(stream, num_instances: int)[source]#
Parameters:
  • stream – The concept to draw instances from.

  • num_instances – How many instances this concept contributes.

get_schema()[source]#