Generated reference › SVM Regression Predictor — Machine Learning/Classical Models
kind: generated#block#machine-learning-classical-models

SVM Regression Predictor — Machine Learning/Classical Models

Machine_Learning/Classical_Models/SVM_Regression_Predictor · 1 input / 1 output port(s) at insert · exports to Python, MATLAB, Java, Rust, C, C++, VHDL, Verilog, SystemVerilog, PLC Structured Text

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.

SVM Regression Predictor

Machine Learning / Classical Models

Evaluates a fitted support vector regression model at inference – what MATLAB's yfit = predict(Mdl, x) returns for a RegressionSVM (ε-SVR, trained with fitrsvm) and one observation:

z = (x − Mu) ./ Sigma,   f = Σi Alphai·K(z/s, SVi/s) + Bias,   y = T(f) – where s is the kernel scale, K the kernel and T the response transform. For the linear kernel the sum is the model's Beta: f = (z/s)·Beta + Bias.

The model is baked in as configuration, pasted from the fitted object; nothing is fitted here and no model file is read.

Ports

  • x – one observation, a column [D,1] with one predictor per row, in the order the model was trained on.
  • y – the predicted response, a scalar [1,1].

Parameters

  • Kernel Function – Mdl.KernelParameters.Function:
    • linear – K = a·b. The default, as in fitrsvm. The model is then given by Beta, and the support vectors are not used.
    • gaussian – K = exp(−‖a − b‖²). MATLAB's 'rbf' is the same kernel and is reported back as gaussian.
    • polynomial – K = (a·b + 1)Order. The 1 is added after both sides are divided by the kernel scale.
  • Beta – Mdl.Beta, [D,1] (a row is accepted): the linear model's coefficients on the standardised, scaled predictors. Used by linear only.
  • Support Vectors – Mdl.SupportVectors, [N,D], one per row. MATLAB stores them standardised when the model was trained with 'Standardize',true, and they are pasted as they are. Used by gaussian and polynomial.
  • Alpha – Mdl.Alpha, N values, one per support vector, already signed (α − α*). Used by gaussian and polynomial.
  • Bias – Mdl.Bias, a scalar. A kernel offset used in training is already folded into it.
  • Kernel Scale – Mdl.KernelParameters.Scale, strictly positive. It divides both the predictors and the support vectors.
  • Polynomial Order – Mdl.KernelParameters.Order, a whole number from 1 to 32. Used by polynomial only.
  • Mu – Mdl.Mu, [1,D], the predictor means of a standardised model. An unstandardised model has none (MATLAB shows []): leave 0. A single value is applied to every predictor.
  • Sigma – Mdl.Sigma, [1,D], the predictor standard deviations. An unstandardised model: leave 1. As in MATLAB, a predictor whose Sigma is 0 is centred but not divided.
  • Response Transform – T, Mdl.ResponseTransform, spelled as MATLAB spells it:
    • none – y = f. The default, and what fitrsvm sets.
    • logit – 1/(1 + e−f).
    • doublelogit – 1/(1 + e−2f).
    • symmetric – 2f − 1.
    • symmetriclogit – 2/(1 + e−f) − 1.
    • sign – −1, 0 or +1 by the sign of f.
    • ismax and symmetricismax – the constant 1: on a single response the only column is always the maximum. That is what MATLAB returns too.
    invlogit is not offered: it takes log(f/(1−f)), complex for any f outside [0,1]. A function handle cannot be pasted as a number either.
  • Sampling Time (s) – zero or less inherits the solver's rate; a positive value runs the block at that period.

Code export

All ten targets: Python, MATLAB, Java, Rust, C, C++, VHDL, Verilog, SystemVerilog and PLC Structured Text. The whole model is baked into the body at export time; there is no tunable parameter, so a refitted model means a re-export. The software targets evaluate exactly the arithmetic above, in the same order.

The HDL story depends on the kernel. A linear model folds – standardisation and scale included – to one affine form w·x + b, and the three HDL targets compute it in genuine Q16.16 fixed point; with none, symmetric, sign, ismax and symmetricismax the whole block stays in fixed point, while logit, doublelogit and symmetriclogit are simulation-only real after f. The gaussian kernel has an exponential and the polynomial kernel raises a standardised, scaled dot product to a power, multiplying its dynamic range with every factor, so for those two the three HDL bodies are simulation-only real arithmetic, quantized at the ports only.

Simulink bridge

None. Simulink's RegressionSVM Predict block (Statistics and Machine Learning Toolbox) exists, but its only model parameter, TrainedLearner, is the name of a fitted model object in the MATLAB workspace. That object cannot be built from support vectors, coefficients and a kernel – RegressionSVM has no public constructor – and a parameter mapping carries one value to one parameter, so neither direction can cross. The bridge reports the block rather than dropping it silently, and it has no parity testbench, which is the documented consequence of that. The arithmetic is checked against MATLAB's own predict instead, and code export verification covers all ten languages in every kernel and transform. The Simulink block also has no SampleTime parameter.

Notes

  • Algebraic and stateless: the output depends only on the current input.
  • Carries no state space. Every kernel but linear is nonlinear, and even a linear model with no transform is affine rather than linear – the Bias is a constant term, which a feed-through state space y = D·x cannot hold.
  • A NaN in x makes MATLAB answer the model's default response; here the NaN propagates to y.
  • Not SVM Predictor. That block is a binary classifier whose output is a label, with scikit-learn's kernel conventions (gamma inside the kernel, no standardisation); this one is MATLAB's regression model and publishes a number.

Code facts#

FactValue
registered typeMachine_Learning/Classical_Models/SVM_Regression_Predictor
familyMachine_Learning/Classical_Models
solver environment classICoreBlock_0_Machine_Learning_1_Classical_Models_2_SVM_Regression_Predictor
sourcesrc/ICoreBlocks/ICoreBlockLibrary/Blocks/Machine_Learning/Classical_Models/SVM_Regression_Predictor/ICoreBlock_0_Machine_Learning_1_Classical_Models_2_SVM_Regression_Predictor.cpp
headersrc/ICoreBlocks/ICoreBlockLibrary/Blocks/Machine_Learning/Classical_Models/SVM_Regression_Predictor/ICoreBlock_0_Machine_Learning_1_Classical_Models_2_SVM_Regression_Predictor.h
default size on canvas150 × 80 px
ports at insert1 in, 1 out
code generators implementedPython, MATLAB, Java, Rust, C, C++, VHDL, Verilog, SystemVerilog, PLC Structured Text

Ports#

#DirectionSignal typeDescription label
1inICoreDoublex
2outICoreDoubley

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
Kernel Functionmsvm::kernelComboSpec()—
Beta1.5—
Support Vectors[0.6; -0.4]—
Alpha[1; -1]—
Bias0.2—
Kernel Scale1—
Polynomial Order3—
Mu0—
Sigma1—
Response Transformnone%~%logit%~%doublelogit%~%symmetric%~%symmetriclogit%~…—

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 path—
port-count rulePortsParam::None
SampleTime parameteryes

Caveat (shown to the user): no bridge: Simulink's RegressionSVM Predict block (statsLibrary) takes its model as TrainedLearner, the NAME of a fitted RegressionSVM object in the MATLAB workspace, and RegressionSVM has no public constructor -- no parameter mapping can build that object from support vectors, Alpha, Bias, kernel scale, Mu and Sigma, or read them back out of a variable name

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).

SVM Regression Predictor — a fitted MATLAB RegressionSVM (epsilon-SVR) at inference z = (x - Mu) ./ Sigma only where Sigma > 0 f = SUM_i Alpha_i * K(z/Scale, SV_i/Scale) + Bias linear: f = (z/Scale)'*Beta + Bias y = T(f) T = ResponseTransform

Read out of R2026a (RegressionSVM.m, CompactRegressionSVM.response, CompactSVMImpl.score, the coder kernels and classreg.learning.transform.*) and measured against predict:

  • Seven fitted models -- gaussian (KernelScale 0.9 and 'auto'), linear (raw, and standardised

at Scale 1.7), polynomial order 2 standardised and order 3 raw, 'rbf' -- all agree with the transcription to 2.3e-14 over 500 queries. 'rbf' is reported back as gaussian.

  • SupportVectors are stored STANDARDISED; Alpha is already signed (alpha - alpha*).
  • A zero Sigma (a constant training column) is skipped, the column left centred -- 2.2e-15.
  • KernelOffset is folded into Bias by fitrsvm; KernelParameters then holds Function and

Scale only.

  • The linear model is Beta: Beta = SV'*Alpha/Scale (4e-16) and predict equals

(z/Scale)*Beta + Bias to 2.4e-15.

  • ResponseTransform accepts MATLAB's nine names. On one column, ismax and symmetricismax are

the constant 1 (the only column is always the maximum) -- measured on 3000 queries -- and invlogit takes log(y/(1-y)), complex for y outside [0,1]: refused here, as Linear_Classifier_Predictor refuses it.

  • A NaN input row makes MATLAB answer the model's DefaultResponse; here NaN propagates.

Sample results#

SVM Regression Predictor — Repeating Sequence Stair: [-2 -1 -0.5 0 0.5 1 2 3], one entry per sampleSVM Regression Predictor — Repeating Sequence Stair: [-2 -1 -0.5 0 0.5 1 2 3], one entry per sample-2024-2-10123inputoutput
tin ICoreDouble-Out-0out ICoreDouble-Out-0
0-2-2.8
0.40.50.95
0.8-2-2.8
1.20.50.95
1.6-2-2.8
20.50.95
2.4-2-2.8
2.80.50.95
3.2-2-2.8
3.60.50.95
4-2-2.8
4.40.50.95
4.8-2-2.8
5.20.50.95

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)0.2 … 1.7
rampRamp: slope 1 from t = 00.2 … 9.05
sineSine Wave: amplitude 1, 2 rad/s, no phase, no bias-1.3 … 1.699
stepStep: 0 -> 1 at t = 1 s0.2 … 1.7

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 50eb791849fca6bdc23368083262ef77a8b27ee2 · produced by docsSample --out <folder> --blocks SVM_Regression_Predictor ECOC_Classifier_Predictor --steps 60 · data docs/generated/samples/Machine_Learning__Classical_Models__SVM_Regression_Predictor.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).