Class PyPredictorRegression

Base class for processing blocks in the MOSAIC pipeline.

JSON configuration

Use these block entries inside a pipeline configuration. Input names must match other blocks in that pipeline; device addresses and file paths must match your setup.

Block entry for a larger pipeline. Params: Python module, channel count, window length, sample rate, random seed, model path, legacy state-dict path, output count. my_regressor is a placeholder module. Window must provide matching 32-channel, 200-sample data; training targets have 8 values. TrainingBuffer must be a TriggerBuffer.

{
  "PyPredictorRegression": {
    "Type": "pypredictorregression",
    "Inputs": ["Window", "TrainingBuffer"],
    "Params": ["my_regressor", 32, 200, 2000, 42, "", "", 8]
  }
}

How Type, Inputs and Params work · Block catalogue and parameter reference

Inheritance
PyPredictorRegression
Namespace: MOSAIC.Models.MachineLearning
Assembly: MOSAIC.dll
Syntax
public sealed class PyPredictorRegression : BaseBlock, INotifyPropertyChanged, INotifyPropertyChanging, ISubscriber, IPublisher, IBaseBlockProps, IJsonExportable, IDisposable, IAsyncDisposable
Remarks

A BaseBlock represents one node in a processing graph. Blocks are typically created and linked based on a JSON configuration (pipeline definition).

Two Rate Properties:

PropertyPurpose
DesiredRate Emission / display rate in Hz. Determines how often a block publishes output. Modified by windowing blocks (e.g. SlidingWindow: input rows/s divided by stride). Used for status monitoring and tick rate display.
SignalRate True sample rate of the underlying signal in Hz. Used for DSP coefficient design (filter cutoffs, FFT bins, spectral resolution). Passes through windowing blocks unchanged — a SlidingWindow with stride 100 at 2000 Hz input still outputs data whose samples are at 2000 Hz, even though the windows arrive at 20 Hz.

Rate Inheritance: Both rates propagate downstream automatically via TryInheritRate(BaseBlock). Publication rates initially fill unset values; use UpdateAndPropagateRate(double, bool) for runtime changes. Sample rates refresh downstream unless a block declares that it derives its own rate.

Publishing: The Publish(object) method is thread-safe and non-blocking. If a publish call is already in progress, the new value is dropped and the block enters a "stumbling" state reflected in Status.

Automatic CSV Logging: Every successful Publish(object) call feeds Dumper whenever one is open. A dumper opens either because the config named a Path — BlockFactory calls InitDumper(IServiceProvider, string?) for every block it builds — or because IsRecording was switched on, which writes to the shared session folder instead. Either way the file is named by DumpFilePrefix. A block whose Path means something other than a recording folder overrides PathIsDumpFolder.

Constructors

PyPredictorRegression(string, double, string, int, int, int, int, int, bool, string)

Declaration
public PyPredictorRegression(string name, double desiredRate, string modulePath, int inChannels = 32, int winLen = 200, int fs = 2000, int randomSeed = 42, int numOutputs = 8, bool skipPreprocess = false, string modelPath = "")
Parameters
Type Name Description
string name
double desiredRate
string modulePath
int inChannels
int winLen
int fs
int randomSeed
int numOutputs
bool skipPreprocess
string modelPath

Fields

VizUpdateIntervalMs

Declaration
private const int VizUpdateIntervalMs = 16
Field Value
Type Description
int

_fs

Declaration
[ObservableProperty]
private int _fs
Field Value
Type Description
int

_inChannels

Declaration
[ObservableProperty]
private int _inChannels
Field Value
Type Description
int

_isTrained

Declaration
[ObservableProperty]
private bool _isTrained
Field Value
Type Description
bool

_isTraining

Declaration
[ObservableProperty]
private bool _isTraining
Field Value
Type Description
bool

_lastVizUpdate

Declaration
private DateTime _lastVizUpdate
Field Value
Type Description
DateTime

_model

Declaration
private dynamic? _model
Field Value
Type Description
dynamic

_modelDescription

Declaration
[ObservableProperty]
private string _modelDescription
Field Value
Type Description
string

_modelPath

Declaration
private readonly string _modelPath
Field Value
Type Description
string

_modulePath

Declaration
[ObservableProperty]
private string _modulePath
Field Value
Type Description
string

_np

Declaration
private dynamic? _np
Field Value
Type Description
dynamic

_numOutputs

Declaration
[ObservableProperty]
private int _numOutputs
Field Value
Type Description
int

_predictionCount

Declaration
[ObservableProperty]
private long _predictionCount
Field Value
Type Description
long

_randomSeed

Declaration
[ObservableProperty]
private int _randomSeed
Field Value
Type Description
int

_skipPreprocess

Declaration
[ObservableProperty]
private bool _skipPreprocess
Field Value
Type Description
bool

_smoothAdaptive

Declaration
[ObservableProperty]
private bool _smoothAdaptive
Field Value
Type Description
bool

_smoothDeadzone

Declaration
[ObservableProperty]
private double _smoothDeadzone
Field Value
Type Description
double

_smoothEnabled

Declaration
[ObservableProperty]
private bool _smoothEnabled
Field Value
Type Description
bool

_smoothTau

Declaration
[ObservableProperty]
private double _smoothTau
Field Value
Type Description
double

_winLen

Declaration
[ObservableProperty]
private int _winLen
Field Value
Type Description
int

Properties

Buffer

Declaration
public TriggerBuffer? Buffer { get; set; }
Property Value
Type Description
TriggerBuffer

DumpFilePrefix

Recordings from this block are named <block>_predictions.csv.

Declaration
protected override string DumpFilePrefix { get; }
Property Value
Type Description
string
Overrides
BaseBlock.DumpFilePrefix

Fs

Declaration
[ExcludeFromCodeCoverage]
public int Fs { get; set; }
Property Value
Type Description
int

InChannels

Declaration
[ExcludeFromCodeCoverage]
public int InChannels { get; set; }
Property Value
Type Description
int

IsTrained

Declaration
[ExcludeFromCodeCoverage]
public bool IsTrained { get; set; }
Property Value
Type Description
bool

IsTraining

Declaration
[ExcludeFromCodeCoverage]
public bool IsTraining { get; set; }
Property Value
Type Description
bool

JsonTypeName

Block type identifier for JSON serialization. Override for a custom name.

Declaration
protected override string JsonTypeName { get; }
Property Value
Type Description
string
Overrides
BaseBlock.JsonTypeName

MaxInputs

Needs exactly two inputs (e.g. a data stream + a Trigger/TriggerBuffer).

Declaration
public override int MaxInputs { get; }
Property Value
Type Description
int
Overrides
BaseBlock.MaxInputs

MinInputs

Needs exactly two inputs (e.g. a data stream + a Trigger/TriggerBuffer).

Declaration
public override int MinInputs { get; }
Property Value
Type Description
int
Overrides
BaseBlock.MinInputs

ModelDescription

Declaration
[ExcludeFromCodeCoverage]
public string ModelDescription { get; set; }
Property Value
Type Description
string

ModulePath

Declaration
[ExcludeFromCodeCoverage]
public string ModulePath { get; set; }
Property Value
Type Description
string

NumOutputs

Declaration
[ExcludeFromCodeCoverage]
public int NumOutputs { get; set; }
Property Value
Type Description
int

PredictionCount

Declaration
[ExcludeFromCodeCoverage]
public long PredictionCount { get; set; }
Property Value
Type Description
long

RandomSeed

Declaration
[ExcludeFromCodeCoverage]
public int RandomSeed { get; set; }
Property Value
Type Description
int

SavePath

Declaration
public string SavePath { get; }
Property Value
Type Description
string

SkipPreprocess

Declaration
[ExcludeFromCodeCoverage]
public bool SkipPreprocess { get; set; }
Property Value
Type Description
bool

SmoothAdaptive

Declaration
[ExcludeFromCodeCoverage]
public bool SmoothAdaptive { get; set; }
Property Value
Type Description
bool

SmoothDeadzone

Declaration
[ExcludeFromCodeCoverage]
public double SmoothDeadzone { get; set; }
Property Value
Type Description
double

SmoothEnabled

Declaration
[ExcludeFromCodeCoverage]
public bool SmoothEnabled { get; set; }
Property Value
Type Description
bool

SmoothTau

Declaration
[ExcludeFromCodeCoverage]
public double SmoothTau { get; set; }
Property Value
Type Description
double

Visualization

This block's visualization, or null when it has none.

Declaration
protected override BlockVisualization? Visualization { get; }
Property Value
Type Description
BlockVisualization
Overrides
BaseBlock.Visualization
Remarks

Blocks own their scope as a public Viz property rather than inheriting one, so the base class has no way to reach it. Overriding this is what lets the rate below be wired up automatically. With correct publication metadata, the bundle derives the time axis for one vector per publication or fixed-size contiguous sample packets from the feed shape.

When a plot needs a rate that publication frequency and feed shape cannot express (for example, variable-sized packets or overlapping windows), declare it with Viz.UpdateSignalRate. An explicit declaration wins over the derived rate. A block with several bundles must configure each one; this hook exposes only one bundle.

Viz

Declaration
public BlockVisualization Viz { get; }
Property Value
Type Description
BlockVisualization

WinLen

Declaration
[ExcludeFromCodeCoverage]
public int WinLen { get; set; }
Property Value
Type Description
int

Methods

ConfigureInput(IServiceProvider, JsonModel)

Declaration
public static PyPredictorRegression ConfigureInput(IServiceProvider sp, JsonModel m)
Parameters
Type Name Description
IServiceProvider sp
JsonModel m
Returns
Type Description
PyPredictorRegression

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

Declaration
public override void Dispose()
Overrides
BaseBlock.Dispose()

FineTune(List<(string Label, Matrix<double> Targets, Matrix<double> Data)>, int, int, int, double, string?)

Declaration
public void FineTune(List<(string Label, Matrix<double> Targets, Matrix<double> Data)> clusters, int epochs = 50, int hop = 100, int batchSize = 32, double lr = 0.005, string? savePath = null)
Parameters
Type Name Description
List<(string Label, Matrix<double> Targets, Matrix<double> Data)> clusters
int epochs
int hop
int batchSize
double lr
string savePath

GetJsonParams()

Block-specific parameters for JSON. Override to provide custom parameters.

Declaration
protected override IReadOnlyList<object>? GetJsonParams()
Returns
Type Description
IReadOnlyList<object>

The values for Params, in the order this block's ConfigureInput reads them, or null when the block takes no parameters.

Overrides
BaseBlock.GetJsonParams()

OnFsChanged(int)

Executes the logic for when Fs just changed.

Declaration
private void OnFsChanged(int value)
Parameters
Type Name Description
int value

The new property value that was set.

Remarks

This method is invoked right after the value of Fs is changed.

OnFsChanged(int, int)

Executes the logic for when Fs just changed.

Declaration
private void OnFsChanged(int oldValue, int newValue)
Parameters
Type Name Description
int oldValue

The previous property value that was replaced.

int newValue

The new property value that was set.

Remarks

This method is invoked right after the value of Fs is changed.

OnFsChanging(int)

Executes the logic for when Fs is changing.

Declaration
private void OnFsChanging(int value)
Parameters
Type Name Description
int value

The new property value being set.

Remarks

This method is invoked right before the value of Fs is changed.

OnFsChanging(int, int)

Executes the logic for when Fs is changing.

Declaration
private void OnFsChanging(int oldValue, int newValue)
Parameters
Type Name Description
int oldValue

The previous property value that is being replaced.

int newValue

The new property value being set.

Remarks

This method is invoked right before the value of Fs is changed.

OnInChannelsChanged(int)

Executes the logic for when InChannels just changed.

Declaration
private void OnInChannelsChanged(int value)
Parameters
Type Name Description
int value

The new property value that was set.

Remarks

This method is invoked right after the value of InChannels is changed.

OnInChannelsChanged(int, int)

Executes the logic for when InChannels just changed.

Declaration
private void OnInChannelsChanged(int oldValue, int newValue)
Parameters
Type Name Description
int oldValue

The previous property value that was replaced.

int newValue

The new property value that was set.

Remarks

This method is invoked right after the value of InChannels is changed.

OnInChannelsChanging(int)

Executes the logic for when InChannels is changing.

Declaration
private void OnInChannelsChanging(int value)
Parameters
Type Name Description
int value

The new property value being set.

Remarks

This method is invoked right before the value of InChannels is changed.

OnInChannelsChanging(int, int)

Executes the logic for when InChannels is changing.

Declaration
private void OnInChannelsChanging(int oldValue, int newValue)
Parameters
Type Name Description
int oldValue

The previous property value that is being replaced.

int newValue

The new property value being set.

Remarks

This method is invoked right before the value of InChannels is changed.

OnIsTrainedChanged(bool)

Executes the logic for when IsTrained just changed.

Declaration
private void OnIsTrainedChanged(bool value)
Parameters
Type Name Description
bool value

The new property value that was set.

Remarks

This method is invoked right after the value of IsTrained is changed.

OnIsTrainedChanged(bool, bool)

Executes the logic for when IsTrained just changed.

Declaration
private void OnIsTrainedChanged(bool oldValue, bool newValue)
Parameters
Type Name Description
bool oldValue

The previous property value that was replaced.

bool newValue

The new property value that was set.

Remarks

This method is invoked right after the value of IsTrained is changed.

OnIsTrainedChanging(bool)

Executes the logic for when IsTrained is changing.

Declaration
private void OnIsTrainedChanging(bool value)
Parameters
Type Name Description
bool value

The new property value being set.

Remarks

This method is invoked right before the value of IsTrained is changed.

OnIsTrainedChanging(bool, bool)

Executes the logic for when IsTrained is changing.

Declaration
private void OnIsTrainedChanging(bool oldValue, bool newValue)
Parameters
Type Name Description
bool oldValue

The previous property value that is being replaced.

bool newValue

The new property value being set.

Remarks

This method is invoked right before the value of IsTrained is changed.

OnIsTrainingChanged(bool)

Executes the logic for when IsTraining just changed.

Declaration
private void OnIsTrainingChanged(bool value)
Parameters
Type Name Description
bool value

The new property value that was set.

Remarks

This method is invoked right after the value of IsTraining is changed.

OnIsTrainingChanged(bool, bool)

Executes the logic for when IsTraining just changed.

Declaration
private void OnIsTrainingChanged(bool oldValue, bool newValue)
Parameters
Type Name Description
bool oldValue

The previous property value that was replaced.

bool newValue

The new property value that was set.

Remarks

This method is invoked right after the value of IsTraining is changed.

OnIsTrainingChanging(bool)

Executes the logic for when IsTraining is changing.

Declaration
private void OnIsTrainingChanging(bool value)
Parameters
Type Name Description
bool value

The new property value being set.

Remarks

This method is invoked right before the value of IsTraining is changed.

OnIsTrainingChanging(bool, bool)

Executes the logic for when IsTraining is changing.

Declaration
private void OnIsTrainingChanging(bool oldValue, bool newValue)
Parameters
Type Name Description
bool oldValue

The previous property value that is being replaced.

bool newValue

The new property value being set.

Remarks

This method is invoked right before the value of IsTraining is changed.

OnModelDescriptionChanged(string)

Executes the logic for when ModelDescription just changed.

Declaration
private void OnModelDescriptionChanged(string value)
Parameters
Type Name Description
string value

The new property value that was set.

Remarks

This method is invoked right after the value of ModelDescription is changed.

OnModelDescriptionChanged(string?, string)

Executes the logic for when ModelDescription just changed.

Declaration
private void OnModelDescriptionChanged(string? oldValue, string newValue)
Parameters
Type Name Description
string oldValue

The previous property value that was replaced.

string newValue

The new property value that was set.

Remarks

This method is invoked right after the value of ModelDescription is changed.

OnModelDescriptionChanging(string)

Executes the logic for when ModelDescription is changing.

Declaration
private void OnModelDescriptionChanging(string value)
Parameters
Type Name Description
string value

The new property value being set.

Remarks

This method is invoked right before the value of ModelDescription is changed.

OnModelDescriptionChanging(string?, string)

Executes the logic for when ModelDescription is changing.

Declaration
private void OnModelDescriptionChanging(string? oldValue, string newValue)
Parameters
Type Name Description
string oldValue

The previous property value that is being replaced.

string newValue

The new property value being set.

Remarks

This method is invoked right before the value of ModelDescription is changed.

OnModulePathChanged(string)

Executes the logic for when ModulePath just changed.

Declaration
private void OnModulePathChanged(string value)
Parameters
Type Name Description
string value

The new property value that was set.

Remarks

This method is invoked right after the value of ModulePath is changed.

OnModulePathChanged(string?, string)

Executes the logic for when ModulePath just changed.

Declaration
private void OnModulePathChanged(string? oldValue, string newValue)
Parameters
Type Name Description
string oldValue

The previous property value that was replaced.

string newValue

The new property value that was set.

Remarks

This method is invoked right after the value of ModulePath is changed.

OnModulePathChanging(string)

Executes the logic for when ModulePath is changing.

Declaration
private void OnModulePathChanging(string value)
Parameters
Type Name Description
string value

The new property value being set.

Remarks

This method is invoked right before the value of ModulePath is changed.

OnModulePathChanging(string?, string)

Executes the logic for when ModulePath is changing.

Declaration
private void OnModulePathChanging(string? oldValue, string newValue)
Parameters
Type Name Description
string oldValue

The previous property value that is being replaced.

string newValue

The new property value being set.

Remarks

This method is invoked right before the value of ModulePath is changed.

OnNumOutputsChanged(int)

Executes the logic for when NumOutputs just changed.

Declaration
private void OnNumOutputsChanged(int value)
Parameters
Type Name Description
int value

The new property value that was set.

Remarks

This method is invoked right after the value of NumOutputs is changed.

OnNumOutputsChanged(int, int)

Executes the logic for when NumOutputs just changed.

Declaration
private void OnNumOutputsChanged(int oldValue, int newValue)
Parameters
Type Name Description
int oldValue

The previous property value that was replaced.

int newValue

The new property value that was set.

Remarks

This method is invoked right after the value of NumOutputs is changed.

OnNumOutputsChanging(int)

Executes the logic for when NumOutputs is changing.

Declaration
private void OnNumOutputsChanging(int value)
Parameters
Type Name Description
int value

The new property value being set.

Remarks

This method is invoked right before the value of NumOutputs is changed.

OnNumOutputsChanging(int, int)

Executes the logic for when NumOutputs is changing.

Declaration
private void OnNumOutputsChanging(int oldValue, int newValue)
Parameters
Type Name Description
int oldValue

The previous property value that is being replaced.

int newValue

The new property value being set.

Remarks

This method is invoked right before the value of NumOutputs is changed.

OnPredictionCountChanged(long)

Executes the logic for when PredictionCount just changed.

Declaration
private void OnPredictionCountChanged(long value)
Parameters
Type Name Description
long value

The new property value that was set.

Remarks

This method is invoked right after the value of PredictionCount is changed.

OnPredictionCountChanged(long, long)

Executes the logic for when PredictionCount just changed.

Declaration
private void OnPredictionCountChanged(long oldValue, long newValue)
Parameters
Type Name Description
long oldValue

The previous property value that was replaced.

long newValue

The new property value that was set.

Remarks

This method is invoked right after the value of PredictionCount is changed.

OnPredictionCountChanging(long)

Executes the logic for when PredictionCount is changing.

Declaration
private void OnPredictionCountChanging(long value)
Parameters
Type Name Description
long value

The new property value being set.

Remarks

This method is invoked right before the value of PredictionCount is changed.

OnPredictionCountChanging(long, long)

Executes the logic for when PredictionCount is changing.

Declaration
private void OnPredictionCountChanging(long oldValue, long newValue)
Parameters
Type Name Description
long oldValue

The previous property value that is being replaced.

long newValue

The new property value being set.

Remarks

This method is invoked right before the value of PredictionCount is changed.

OnRandomSeedChanged(int)

Executes the logic for when RandomSeed just changed.

Declaration
private void OnRandomSeedChanged(int value)
Parameters
Type Name Description
int value

The new property value that was set.

Remarks

This method is invoked right after the value of RandomSeed is changed.

OnRandomSeedChanged(int, int)

Executes the logic for when RandomSeed just changed.

Declaration
private void OnRandomSeedChanged(int oldValue, int newValue)
Parameters
Type Name Description
int oldValue

The previous property value that was replaced.

int newValue

The new property value that was set.

Remarks

This method is invoked right after the value of RandomSeed is changed.

OnRandomSeedChanging(int)

Executes the logic for when RandomSeed is changing.

Declaration
private void OnRandomSeedChanging(int value)
Parameters
Type Name Description
int value

The new property value being set.

Remarks

This method is invoked right before the value of RandomSeed is changed.

OnRandomSeedChanging(int, int)

Executes the logic for when RandomSeed is changing.

Declaration
private void OnRandomSeedChanging(int oldValue, int newValue)
Parameters
Type Name Description
int oldValue

The previous property value that is being replaced.

int newValue

The new property value being set.

Remarks

This method is invoked right before the value of RandomSeed is changed.

OnReceive(object, object)

Processes incoming data from an upstream block. Must be implemented by derived classes.

Declaration
protected override void OnReceive(object sender, object data)
Parameters
Type Name Description
object sender

The publishing block, or whatever else delivered the value.

object data
Overrides
BaseBlock.OnReceive(object, object)
Remarks

Called on the dispatching thread, not the UI thread.

OnSkipPreprocessChanged(bool)

Executes the logic for when SkipPreprocess just changed.

Declaration
private void OnSkipPreprocessChanged(bool value)
Parameters
Type Name Description
bool value

The new property value that was set.

Remarks

This method is invoked right after the value of SkipPreprocess is changed.

OnSkipPreprocessChanged(bool, bool)

Executes the logic for when SkipPreprocess just changed.

Declaration
private void OnSkipPreprocessChanged(bool oldValue, bool newValue)
Parameters
Type Name Description
bool oldValue

The previous property value that was replaced.

bool newValue

The new property value that was set.

Remarks

This method is invoked right after the value of SkipPreprocess is changed.

OnSkipPreprocessChanging(bool)

Executes the logic for when SkipPreprocess is changing.

Declaration
private void OnSkipPreprocessChanging(bool value)
Parameters
Type Name Description
bool value

The new property value being set.

Remarks

This method is invoked right before the value of SkipPreprocess is changed.

OnSkipPreprocessChanging(bool, bool)

Executes the logic for when SkipPreprocess is changing.

Declaration
private void OnSkipPreprocessChanging(bool oldValue, bool newValue)
Parameters
Type Name Description
bool oldValue

The previous property value that is being replaced.

bool newValue

The new property value being set.

Remarks

This method is invoked right before the value of SkipPreprocess is changed.

OnSmoothAdaptiveChanged(bool)

Executes the logic for when SmoothAdaptive just changed.

Declaration
private void OnSmoothAdaptiveChanged(bool value)
Parameters
Type Name Description
bool value

The new property value that was set.

Remarks

This method is invoked right after the value of SmoothAdaptive is changed.

OnSmoothAdaptiveChanged(bool, bool)

Executes the logic for when SmoothAdaptive just changed.

Declaration
private void OnSmoothAdaptiveChanged(bool oldValue, bool newValue)
Parameters
Type Name Description
bool oldValue

The previous property value that was replaced.

bool newValue

The new property value that was set.

Remarks

This method is invoked right after the value of SmoothAdaptive is changed.

OnSmoothAdaptiveChanging(bool)

Executes the logic for when SmoothAdaptive is changing.

Declaration
private void OnSmoothAdaptiveChanging(bool value)
Parameters
Type Name Description
bool value

The new property value being set.

Remarks

This method is invoked right before the value of SmoothAdaptive is changed.

OnSmoothAdaptiveChanging(bool, bool)

Executes the logic for when SmoothAdaptive is changing.

Declaration
private void OnSmoothAdaptiveChanging(bool oldValue, bool newValue)
Parameters
Type Name Description
bool oldValue

The previous property value that is being replaced.

bool newValue

The new property value being set.

Remarks

This method is invoked right before the value of SmoothAdaptive is changed.

OnSmoothDeadzoneChanged(double)

Executes the logic for when SmoothDeadzone just changed.

Declaration
private void OnSmoothDeadzoneChanged(double value)
Parameters
Type Name Description
double value

The new property value that was set.

Remarks

This method is invoked right after the value of SmoothDeadzone is changed.

OnSmoothDeadzoneChanged(double, double)

Executes the logic for when SmoothDeadzone just changed.

Declaration
private void OnSmoothDeadzoneChanged(double oldValue, double newValue)
Parameters
Type Name Description
double oldValue

The previous property value that was replaced.

double newValue

The new property value that was set.

Remarks

This method is invoked right after the value of SmoothDeadzone is changed.

OnSmoothDeadzoneChanging(double)

Executes the logic for when SmoothDeadzone is changing.

Declaration
private void OnSmoothDeadzoneChanging(double value)
Parameters
Type Name Description
double value

The new property value being set.

Remarks

This method is invoked right before the value of SmoothDeadzone is changed.

OnSmoothDeadzoneChanging(double, double)

Executes the logic for when SmoothDeadzone is changing.

Declaration
private void OnSmoothDeadzoneChanging(double oldValue, double newValue)
Parameters
Type Name Description
double oldValue

The previous property value that is being replaced.

double newValue

The new property value being set.

Remarks

This method is invoked right before the value of SmoothDeadzone is changed.

OnSmoothEnabledChanged(bool)

Executes the logic for when SmoothEnabled just changed.

Declaration
private void OnSmoothEnabledChanged(bool value)
Parameters
Type Name Description
bool value

The new property value that was set.

Remarks

This method is invoked right after the value of SmoothEnabled is changed.

OnSmoothEnabledChanged(bool, bool)

Executes the logic for when SmoothEnabled just changed.

Declaration
private void OnSmoothEnabledChanged(bool oldValue, bool newValue)
Parameters
Type Name Description
bool oldValue

The previous property value that was replaced.

bool newValue

The new property value that was set.

Remarks

This method is invoked right after the value of SmoothEnabled is changed.

OnSmoothEnabledChanging(bool)

Executes the logic for when SmoothEnabled is changing.

Declaration
private void OnSmoothEnabledChanging(bool value)
Parameters
Type Name Description
bool value

The new property value being set.

Remarks

This method is invoked right before the value of SmoothEnabled is changed.

OnSmoothEnabledChanging(bool, bool)

Executes the logic for when SmoothEnabled is changing.

Declaration
private void OnSmoothEnabledChanging(bool oldValue, bool newValue)
Parameters
Type Name Description
bool oldValue

The previous property value that is being replaced.

bool newValue

The new property value being set.

Remarks

This method is invoked right before the value of SmoothEnabled is changed.

OnSmoothTauChanged(double)

Executes the logic for when SmoothTau just changed.

Declaration
private void OnSmoothTauChanged(double value)
Parameters
Type Name Description
double value

The new property value that was set.

Remarks

This method is invoked right after the value of SmoothTau is changed.

OnSmoothTauChanged(double, double)

Executes the logic for when SmoothTau just changed.

Declaration
private void OnSmoothTauChanged(double oldValue, double newValue)
Parameters
Type Name Description
double oldValue

The previous property value that was replaced.

double newValue

The new property value that was set.

Remarks

This method is invoked right after the value of SmoothTau is changed.

OnSmoothTauChanging(double)

Executes the logic for when SmoothTau is changing.

Declaration
private void OnSmoothTauChanging(double value)
Parameters
Type Name Description
double value

The new property value being set.

Remarks

This method is invoked right before the value of SmoothTau is changed.

OnSmoothTauChanging(double, double)

Executes the logic for when SmoothTau is changing.

Declaration
private void OnSmoothTauChanging(double oldValue, double newValue)
Parameters
Type Name Description
double oldValue

The previous property value that is being replaced.

double newValue

The new property value being set.

Remarks

This method is invoked right before the value of SmoothTau is changed.

OnWinLenChanged(int)

Executes the logic for when WinLen just changed.

Declaration
private void OnWinLenChanged(int value)
Parameters
Type Name Description
int value

The new property value that was set.

Remarks

This method is invoked right after the value of WinLen is changed.

OnWinLenChanged(int, int)

Executes the logic for when WinLen just changed.

Declaration
private void OnWinLenChanged(int oldValue, int newValue)
Parameters
Type Name Description
int oldValue

The previous property value that was replaced.

int newValue

The new property value that was set.

Remarks

This method is invoked right after the value of WinLen is changed.

OnWinLenChanging(int)

Executes the logic for when WinLen is changing.

Declaration
private void OnWinLenChanging(int value)
Parameters
Type Name Description
int value

The new property value being set.

Remarks

This method is invoked right before the value of WinLen is changed.

OnWinLenChanging(int, int)

Executes the logic for when WinLen is changing.

Declaration
private void OnWinLenChanging(int oldValue, int newValue)
Parameters
Type Name Description
int oldValue

The previous property value that is being replaced.

int newValue

The new property value being set.

Remarks

This method is invoked right before the value of WinLen is changed.

Predict(Matrix<double>)

Declaration
private void Predict(Matrix<double> inputMatrix)
Parameters
Type Name Description
Matrix<double> inputMatrix

PushSmoothingConfig()

Push current C# smoothing properties to the Python model. Called automatically when any smoothing property changes.

Declaration
private void PushSmoothingConfig()

ResetModel()

Full reset: reinitialises the model with random weights and clears all replay buffers, training history, and smoother state. Call this to start training from scratch.

Declaration
public void ResetModel()

ResetSmoother()

Resets only the output smoother so the next prediction starts fresh. Useful after a pause or context switch.

Declaration
public void ResetSmoother()

ResetToCheckpoint()

Reloads the model weights from the checkpoint file that was passed at construction (state_dict_path). Falls back to a full random reset if no checkpoint was provided. Also clears replay buffers and smoother.

Declaration
public void ResetToCheckpoint()

StackClusters(List<(string Label, Matrix<double> Targets, Matrix<double> Data)>)

Stacks segment matrices and appends the per-row target vector as trailing columns. With the buffer's new (string Label, Matrix Targets, Matrix Data) shape, each data row has its own target row (1:1 indexing when data is vector-per-tick; in image cases the caller is responsible for handling the row-count mismatch upstream). For classification-style senders the target rows are all identical; for streaming triggers they vary across time, which is what enables true regression on continuous activations.

Declaration
private static Matrix<double> StackClusters(List<(string Label, Matrix<double> Targets, Matrix<double> Data)> clusters)
Parameters
Type Name Description
List<(string Label, Matrix<double> Targets, Matrix<double> Data)> clusters
Returns
Type Description
Matrix<double>

TrainIncremental(List<(string Label, Matrix<double> Targets, Matrix<double> Data)>, int, int, int, double, bool, double, bool, int, string?)

Declaration
public void TrainIncremental(List<(string Label, Matrix<double> Targets, Matrix<double> Data)> clusters, int epochs = 100, int hop = 100, int batchSize = 32, double lr = 0.001, bool useDistillation = false, double replayRatio = 0, bool jointFinetune = false, int jointEpochs = 30, string? savePath = null)
Parameters
Type Name Description
List<(string Label, Matrix<double> Targets, Matrix<double> Data)> clusters
int epochs
int hop
int batchSize
double lr
bool useDistillation
double replayRatio
bool jointFinetune
int jointEpochs
string savePath

UpdateDescription()

Declaration
private void UpdateDescription()

Events

OnBufferSegmentAdded

Declaration
public event Action? OnBufferSegmentAdded
Event Type
Type Description
Action

OnPrediction

Declaration
public event Action<Vector<double>>? OnPrediction
Event Type
Type Description
Action<Vector<double>>

OnTrainingStateChanged

Declaration
public event Action<bool>? OnTrainingStateChanged
Event Type
Type Description
Action<bool>

Implements

INotifyPropertyChanged
INotifyPropertyChanging
ISubscriber
IPublisher
IBaseBlockProps
IJsonExportable
IDisposable
IAsyncDisposable

Search documentation

Start typing to search the documentation.