Generated reference › Incremental Regression Linear Fit — Machine Learning/Incremental Learning
kind: generated#block#machine-learning-incremental-learning

Incremental Regression Linear Fit — Machine Learning/Incremental Learning

Machine_Learning/Incremental_Learning/Incremental_Regression_Linear_Fit · 2 input / 1 output port(s) at insert · exports to Python, MATLAB, Java, Rust, C, C++

Description#

The block's own DESCRIPTION_HTML, rendered verbatim — the same text the config dialog's info panel and the library navigator show. Fix a wrong sentence in the block's .cpp (R-D9), never here.

Incremental Regression Linear Fit

Machine Learning / Incremental Learning

Fits a linear regression model online, one observation per step, and puts the model on a bus every step: y ≈ x·β + b. This is MATLAB's incrementalRegressionLinear learner with its default scale-invariant solver (Statistics and Machine Learning Toolbox), as Simulink's IncrementalRegressionLinear Fit block runs it. The first Estimation Period observations are used only to estimate what the learner estimates (the predictors' means and standard deviations under Standardize, and Epsilon); every later one updates β and b. Feed the bus to an IncrementalRegressionLinear Predict block.

Ports

  • x – one observation of the P predictors, a row [1,P]. P is read off this width.
  • y – the response of that observation, [1,1]. A NaN in x or y skips the observation, where Simulink's block lets it in: a NaN predictor turns its Beta NaN for the rest of the run, and a NaN response still moves it.
  • mdl (bus) – the learner after this observation, a bus of seven elements: Beta [P,1], Bias [1,1], IsWarm (bool, true once Metrics Warmup Period observations have been trained on), CanPredict (bool, false only while standardization is still being estimated), Mu [P,1] and Sigma [P,1] (the standardization, 0 and 1 when there is none) and Epsilon [1,1] (0 for the leastsquares learner).

Parameters

  • Learner – the loss the solver minimizes:
    • svm (the default) – the epsilon-insensitive loss of a support vector machine regression;
    • leastsquares – the squared error.
  • Epsilon – half the width of the svm loss's insensitive band, 0.1 by default; not used by leastsquares.
  • Estimate Epsilon – on (the default, MATLAB's 'auto'): Epsilon is re-estimated from the responses of the estimation period, as their interquartile range divided by 13.49 (0.1 when that is zero); off: Epsilon stays as set.
  • Standardize – off (the default) or on: center and scale each predictor by its mean and standard deviation over the estimation period.
  • Estimation Period – how many observations the estimation uses, 1000 by default as in MATLAB. It applies only when something is estimated (Standardize on, or the svm learner with Estimate Epsilon on); otherwise every observation trains.
  • Metrics Warmup Period – how many trained observations make the model warm (IsWarm), 1000 by default.
  • Sampling Time (s) – zero or less inherits the solver's rate; a positive value runs the block at that period.

When a run is refused

An x that is not a row, a y that is not [1,1], a negative or fractional period, a negative Epsilon, or Standardize on with an Estimation Period of 0.

Code export

Six targets: Python, MATLAB, Java, Rust, C and C++, each carrying the learner's whole state and running the same step as the live block, in the same arithmetic order. The hardware targets (VHDL, Verilog, SystemVerilog) and PLC Structured Text carry no bus, so an export to one stops and names the block.

Simulink bridge

None. Simulink's block takes its learner as InitialLearner, the name of an incrementalRegressionLinear object in the MATLAB workspace, rather than as dialog parameters, so there is nothing in its dialog to map these configs onto or read them back from.

Notes

  • Stateful: the state is the solver's (four running sums per coefficient and the largest response seen), the estimation sums, and the counts.
  • The bus at a step has already learnt that step's observation, as in Simulink: a Predict block fed the same x sees a model trained on it.
  • Timing follows Simulink's block, not MATLAB's fit(): the estimated Mu, Sigma and Epsilon appear one step after the estimation period ends, and IsWarm turns true one step after fit() would set it.
  • A predictor that does not vary over the estimation period gets Sigma 0 and is left unscaled, as MATLAB's learner leaves it; Simulink's block divides by that zero and its Beta turns NaN.
  • One observation per step; Simulink's block also takes several rows at a time, and its optional weights and reset inputs are not offered.
  • Verified against R2026a: over 120 steps in four configurations (svm with Epsilon estimated, leastsquares standardized, svm with a fixed Epsilon, svm standardized), Beta and Bias agree with Simulink's block within 10−14, and IsWarm, CanPredict, Mu, Sigma and Epsilon at every step.

Code facts#

FactValue
registered typeMachine_Learning/Incremental_Learning/Incremental_Regression_Linear_Fit
familyMachine_Learning/Incremental_Learning
solver environment classICoreBlock_0_Machine_Learning_1_Incremental_Learning_2_Incremental_Regression_Linear_Fit
sourcesrc/ICoreBlocks/ICoreBlockLibrary/Blocks/Machine_Learning/Incremental_Learning/Incremental_Regression_Linear_Fit/ICoreBlock_0_Machine_Learning_1_Incremental_Learning_2_Incremental_Regression_Linear_Fit.cpp
headersrc/ICoreBlocks/ICoreBlockLibrary/Blocks/Machine_Learning/Incremental_Learning/Incremental_Regression_Linear_Fit/ICoreBlock_0_Machine_Learning_1_Incremental_Learning_2_Incremental_Regression_Linear_Fit.h
default size on canvas150 × 80 px
ports at insert2 in, 1 out
code generators implementedPython, MATLAB, Java, Rust, C, C++

Ports#

#DirectionSignal typeDescription label
1inICoreDoublex
2inICoreDoubley
3outICoreBusmdl

Ports the constructor creates. A block whose port list changes with its configuration adds or removes ports at load time; the count above is the one a freshly inserted block has.

Configuration variables#

Config variableDefaultSimulink parameter
Learnersvm%~%leastsquares~~svm—
Epsilon0.1—
Estimate Epsilonon%~%off~~on—
Standardizeoff%~%on~~off—
Estimation Period1000—
Metrics Warmup Period1000—

Every block also carries Sampling Time (s) from ICoreBlockSolverEnvironment: zero or less inherits the solver's rate, a positive value runs the block at that period.

supportSupport::None
Simulink pathstatsIncremental/Regression/Linear/IncrementalRegressionLinear Fit
port-count rulePortsParam::None
SampleTime parameteryes

Caveat (shown to the user): no bridge: Simulink's IncrementalRegressionLinear Fit block takes its learner as InitialLearner, the NAME of an incrementalRegressionLinear object in the MATLAB workspace, not as dialog parameters -- there is nothing in its dialog to map the learner configs onto, or read them back from

Catalog contract: src/ICoreBlocks/ICoreCoder/ICoreCommandSystem/SimulinkBridge/ICoreSimulinkBlockCatalog.h

Description vs code#

The lists agree. check_block_descriptions.py finds no disagreement between the description's Ports, Parameters, Code export and Simulink bridge lists and the code's.

The verdict above is tools/docs/check_block_descriptions.py (P7.1), which compares LISTS. It cannot read a sentence: "stateless" on a block with a state, an initial-value semantic the recursion does not implement, a "not synthesizable" caveat the HDL banner contradicts. That is the agent audit (P7.3) on BLOCK_DESCRIPTION_AUDIT.md, and this tool's green is not a substitute for one.

File banner (developer view)#

The top comment of the block's .cpp — the maths, the realization and the export strategy, addressed to whoever changes it. It must not contradict the description above (P7.5).

IncrementalRegressionLinear Fit -- an online linear regression, its model on a bus statsIncremental/Regression/Linear/IncrementalRegressionLinear Fit, MEASURED on R2026a 2026-10-02 (BLOCKS_TO_ADD_TOOLBOXES.md statsIncremental, on FEATURES_TO_ADD.md BF1). Simulink's block takes its learner as InitialLearner, the name of an incrementalRegressionLinear object in the MATLAB workspace; here the learner's options are configs: Learner (svm, leastsquares), Epsilon and whether it is estimated (MATLAB's 'auto'), Standardize, EstimationPeriod and MetricsWarmupPeriod, with MATLAB's defaults. The predictor count is x's width.

The solver is MATLAB's scale-invariant one (the coder transcription in +incremental/+coder/+impl/ScaleInvariantImpl.m), and the block follows the Simulink block's timing, which differs from the object's fit() in two measured ways: the estimated Mu, Sigma and Epsilon are published one step after the estimation period ends, and IsWarm flips one step later. Against the Simulink block over 120 steps in four configurations: Beta and Bias within 1e-14, every flag exact.

The output bus is Simulink's, element for element: Beta [P,1], Bias, IsWarm (Bool), CanPredict (Bool), Mu [P,1], Sigma [P,1], Epsilon. Simulink's Mu and Sigma are 1-D [P]; here they are columns.

Sample results#

Incremental Regression Linear Fit — Repeating Sequence Stair: [-2 -1 -0.5 0 0.5 1 2 3], one entry per sampleIncremental Regression Linear Fit — Repeating Sequence Stair: [-2 -1 -0.5 0 0.5 1 2 3], one entry per sample-202012345t (s)in ICoreDouble-Out-0in ICoreDouble-Out-0

This block carries a ICoreBus signal, whose value is text rather than a number and is not something a plot has an axis for. The samples are in the table below, exactly as the run recorded them.

tin ICoreDouble-Out-0in ICoreDouble-Out-0out ICoreBus-Out-0
0-2-2{'Beta': 0, 'Bias': 0, 'IsWarm': 0, 'CanPredict': 1, 'Mu': 0, 'Sigma': 1, 'Epsilon': 0.1}
0.40.50.5{'Beta': 0, 'Bias': 0, 'IsWarm': 0, 'CanPredict': 1, 'Mu': 0, 'Sigma': 1, 'Epsilon': 0.1}
0.8-2-2{'Beta': 0, 'Bias': 0, 'IsWarm': 0, 'CanPredict': 1, 'Mu': 0, 'Sigma': 1, 'Epsilon': 0.1}
1.20.50.5{'Beta': 0, 'Bias': 0, 'IsWarm': 0, 'CanPredict': 1, 'Mu': 0, 'Sigma': 1, 'Epsilon': 0.1}
1.6-2-2{'Beta': 0, 'Bias': 0, 'IsWarm': 0, 'CanPredict': 1, 'Mu': 0, 'Sigma': 1, 'Epsilon': 0.1}
20.50.5{'Beta': 0, 'Bias': 0, 'IsWarm': 0, 'CanPredict': 1, 'Mu': 0, 'Sigma': 1, 'Epsilon': 0.1}
2.4-2-2{'Beta': 0, 'Bias': 0, 'IsWarm': 0, 'CanPredict': 1, 'Mu': 0, 'Sigma': 1, 'Epsilon': 0.1}
2.80.50.5{'Beta': 0, 'Bias': 0, 'IsWarm': 0, 'CanPredict': 1, 'Mu': 0, 'Sigma': 1, 'Epsilon': 0.1}
3.2-2-2{'Beta': 0, 'Bias': 0, 'IsWarm': 0, 'CanPredict': 1, 'Mu': 0, 'Sigma': 1, 'Epsilon': 0.1}
3.60.50.5{'Beta': 0, 'Bias': 0, 'IsWarm': 0, 'CanPredict': 1, 'Mu': 0, 'Sigma': 1, 'Epsilon': 0.1}
4-2-2{'Beta': 0, 'Bias': 0, 'IsWarm': 0, 'CanPredict': 1, 'Mu': 0, 'Sigma': 1, 'Epsilon': 0.1}
4.40.50.5{'Beta': 0, 'Bias': 0, 'IsWarm': 0, 'CanPredict': 1, 'Mu': 0, 'Sigma': 1, 'Epsilon': 0.1}
4.8-2-2{'Beta': 0, 'Bias': 0, 'IsWarm': 0, 'CanPredict': 1, 'Mu': 0, 'Sigma': 1, 'Epsilon': 0.1}
5.20.50.5{'Beta': 0, 'Bias': 0, 'IsWarm': 0, 'CanPredict': 1, 'Mu': 0, 'Sigma': 1, 'Epsilon': 0.1}

Every 4th of 60 samples, from the table stimulus.

The same rig also ran:

StimulusWhat it isOutput range
impulseImpulse: one sample of 1 at k = 5, 0 elsewhere (Repeating Sequence Stair)—
rampRamp: slope 1 from t = 0—
sineSine Wave: amplitude 1, 2 rad/s, no phase, no bias—
stepStep: 0 -> 1 at t = 1 s—

Plotted: table — Repeating Sequence Stair: [-2 -1 -0.5 0 0.5 1 2 3], one entry per sample

Category static · sample time 0.1 · 60 steps · commit 68af3e6d2 · produced by docsSample --out <folder> --blocks Incremental_Regression_Linear_Fit Incremental_Regression_Linear_Predict Incremental_Classification_Linear_Fit Incremental_Classification_Linear_Predict --steps 60 · data docs/generated/samples/Machine_Learning__Incremental_Learning__Incremental_Regression_Linear_Fit.json · the SVG is generated from those numbers by tools/docs/plot_svg.py, so it is a run and not a drawing (R-D10).