InstanceSpace Python v0.4.1

instancespace.stages.stage

Generic stage.

class Stage(abc.ABC, typing.Generic[~IN, ~OUT]):

Generic stage.

class PredictiveStage(abc.ABC, typing.Generic[~PREDICT_IN, ~FITTED, ~PREDICT_OUT]):

Optional contract for applying a fitted stage to unseen data.

This is separate from Stage so build-only stages and plugins do not need to implement inference, and so the build-only StageRunner contract remains unchanged.

@staticmethod
@abstractmethod
def predict(inputs: ~PREDICT_IN, fitted: ~FITTED) -> ~PREDICT_OUT:

Apply fitted state without training or mutating it.

StageClass = type[Stage[typing.Any, typing.Any]]

The class of a stage.

Used to annotate type when referencing a stage generically.

Usage::

list_of_classes: list[StageClass] = [PrelimStage, CloisterStage]
class RunBefore(typing.Generic[~T]):

Marks that a stage should be run before another stage.

Usage::

class MyInput(NamedTuple):
    run_before: RunBefore[SomeStage] = RunBefore()
    ...
class RunAfter(typing.Generic[~T]):

Marks that a stage should be run after another stage.

Usage::

class MyInput(NamedTuple):
    run_after: RunAfter[SomeStage] = RunAfter()
    ...