ezmsg.learn.collection.sample_adapt_regressor#

Module Attributes

DEFAULT_TORCH_MODEL_CLASS

Default torch model class used when model_type == "mlp".

Functions

build_sample_adapt_regressor(settings)[source]#

Build a decode collection wired around a single regressor engine.

The regressor backend (River/sklearn, torch-mlp, or refit-Kalman) is selected from settings.model_type and the collection class is defined dynamically so the graph contains exactly the units that backend uses — no inert, declared-but-unwired units. The signal path (and, for the linear engine, the online-adaptation sample path) wire to that one unit, so there is no per- backend wiring to keep in sync.

Return type:

Collection

Parameters:

settings (SampleAdaptRegressorSettings)

Classes

class DecodeOutputAdapter(*args, settings=None, **kwargs)[source]#

Bases: BaseTransformerUnit[DecodeOutputAdapterSettings, AxisArray, AxisArray, DecodeOutputAdapterProcessor]

Parameters:

settings (Settings | None)

SETTINGS#

alias of DecodeOutputAdapterSettings

class DecodeOutputAdapterProcessor(*args, **kwargs)[source]#

Bases: BaseStatefulTransformer[DecodeOutputAdapterSettings, AxisArray, AxisArray, DecodeOutputAdapterState]

Normalize a decoder output into a (time, ch) AxisArray.

The torch ({"output": ...}-keyed) and Kalman (["time", "state"]) engines emit differently-shaped outputs than the River/sklearn regressor. This rebuilds a uniform (time, ch=output_labels) message — keyed <input>_pred like AdaptiveLinearRegressorUnit — so downstream consumers see one contract regardless of backend.

class DecodeOutputAdapterSettings(output_labels=None)[source]#

Bases: Settings

Parameters:

output_labels (list | None)

output_labels: list | None = None#

Channel labels for the decoded output. None -> generic ch0..chN.

__init__(output_labels=None)#
Parameters:

output_labels (list | None)

Return type:

None

class DecodeOutputAdapterState[source]#

Bases: object

ch_axis: CoordinateAxis | None = None#
class SampleAdaptRegressorSettings(model_type=AdaptiveLinearRegressor.LINEAR, model_path=None, model_kwargs=<factory>, model_class='ezmsg.learn.model.mlp.MLP', device=None, steady_state=True, output_labels=None, resample_axis='time', resample_buffer_duration=2.0, sampler_max_buffer_dur=5.0, decode_window_dur=None, decode_window_shift=None)[source]#

Bases: Settings

Parameters:
model_type: AdaptiveLinearRegressor | str = 'linear'#

Regressor backend/model.

model_path: str | None = None#

Optional path to a pre-trained checkpoint. Format depends on the backend: a pickled River/sklearn estimator, a torch.save artifact (mlp), or a pickled state-space matrix dict (kalman).

model_kwargs: dict#

Extra kwargs passed to the underlying regressor.

model_class: str = 'ezmsg.learn.model.mlp.MLP'#

Fully-qualified torch model class used when model_type == "mlp".

device: str | None = None#

Torch device for the mlp backend. None -> auto (cuda/mps/cpu).

steady_state: bool = True#

Kalman steady-state gain flag, used when model_type == "kalman".

__init__(model_type=AdaptiveLinearRegressor.LINEAR, model_path=None, model_kwargs=<factory>, model_class='ezmsg.learn.model.mlp.MLP', device=None, steady_state=True, output_labels=None, resample_axis='time', resample_buffer_duration=2.0, sampler_max_buffer_dur=5.0, decode_window_dur=None, decode_window_shift=None)#
Parameters:
Return type:

None

output_labels: list | None = None#

Decoded-output channel labels for the mlp/kalman adapter. None -> generic ch0..chN.

resample_axis: str = 'time'#

Axis to resample along.

resample_buffer_duration: float = 2.0#

Duration of the buffer for resampling in seconds.

sampler_max_buffer_dur: float = 5.0#

Maximum buffer duration for the SeqSeqSampler in seconds.

decode_window_dur: float | None = None#

Optional inference-side feature window duration in seconds.

decode_window_shift: float | None = None#

Optional inference-side feature window shift in seconds.