Generated reference › Standard Scaler — Machine Learning/Preprocessing
kind: generated#block#machine-learning-preprocessing

Standard Scaler — Machine Learning/Preprocessing

Machine_Learning/Preprocessing/Standard_Scaler · 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.

Standard Scaler

Machine Learning / Preprocessing

Per-feature standardization, the step that belongs in front of almost every trained model: y = (u − mean) ÷ scale. It is scikit-learn's StandardScaler at inference – mean_ and scale_ stop being fitted quantities once training is over, so you paste them in as columns and the block is plain arithmetic.

Set Direction to Inverse for the other half of a deployed pipeline, y = u × scale + mean, which is what turns a model's standardized prediction back into engineering units.

Ports

  • u – the feature column, [m,1], where m is the number of entries in Mean and Scale. The size is checked rather than broadcast.
  • Outputy, the same [m,1] shape: this block rescales a signal, it never changes its dimensions.

Parameters

  • Meanmean, an [m,1] column, one per feature. This is scaler.mean_. A zero column turns the block into a pure scaling.
  • Scalescale, an [m,1] column, one per feature: scaler.scale_, which is the standard deviation for a scaler fitted with with_std=True. A column of ones turns the block into pure centering. An entry of exactly zero is replaced by one, matching scikit-learn's own rule for a feature with no variance – a constant feature is passed through rather than making the whole vector infinite.
  • Direction
    • Standardize – y = (u − mean) ÷ scale, the forward transform that feeds a model.
    • Inverse – y = u × scale + mean, which undoes it. Use it on a model's output to recover engineering units.
  • 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. mean and scale are baked into the generated code as literals at full precision; there is no tunable parameter, because a fitted statistic is not something to retune on the target.

The three HDL targets are genuine Q16.16 fixed point and synthesizable – there is nothing transcendental in an affine map. To keep them so, Scale is inverted once when the configuration is loaded and the datapath multiplies by the reciprocal; a divider per sample is what would have made them simulation-only. The same reciprocal is used by the block itself, so the exported core and the in-app run compute bit-identical values rather than agreeing only to a rounding.

Simulink bridge

None, and the first reason is about this installation rather than about Simulink: neither the Statistics and Machine Learning Toolbox nor the Deep Learning Toolbox is installed here, so a bridge could not be run against a parity testbench even if one were written. Base Simulink also offers no fitted-scaler block – standardization there is built from a Constant, a Sum and a Gain, and mapping this block onto any one of them would assert an equivalence that is false for the other two. The bridge reports the block rather than dropping it silently, and it has no parity testbench, which is the documented consequence of Support::None rather than a gap. Code export verification still covers it across all ten languages.

Notes

  • Algebraic and stateless: the output depends only on the current input, so the block cannot break an algebraic loop.
  • No state space, deliberately. The map is affine rather than linear – y = C·x + D·u has nowhere to put the −mean ÷ scale offset – so a stored A/B/C/D would be true only when the mean is zero. Model reduction reports the block as unmergeable, which is the honest answer.
  • The block is a column map: feed one sample at a time. A matrix input is reported rather than treated as a batch.
  • Standardize and Inverse are exact inverses of one another only up to floating-point rounding; chaining the two back to back returns the input to within a few ulp, not bit-for-bit.

Code facts#

FactValue
registered typeMachine_Learning/Preprocessing/Standard_Scaler
familyMachine_Learning/Preprocessing
solver environment classICoreBlock_0_Machine_Learning_1_Preprocessing_2_Standard_Scaler
sourcesrc/ICoreSDK/ICoreBlockLibrary/Blocks/Machine_Learning/Preprocessing/Standard_Scaler/ICoreBlock_0_Machine_Learning_1_Preprocessing_2_Standard_Scaler.cpp
headersrc/ICoreSDK/ICoreBlockLibrary/Blocks/Machine_Learning/Preprocessing/Standard_Scaler/ICoreBlock_0_Machine_Learning_1_Preprocessing_2_Standard_Scaler.h
default size on canvas120 × 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
1inICoreDoubleu
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
Mean[0.4; -1.2; 2]
Scale[2; 0.5; 4]
DirectionStandardize%~%Inverse~~Standardize

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 verifiable Simulink equivalent. Neither the Statistics and Machine Learning Toolbox nor the Deep Learning Toolbox is installed on this machine, so a bridge could not be run against a parity testbench even if one were written. Base Simulink offers no fitted-scaler block in any case: standardization there is assembled from a Constant, a Sum and a Gain, and mapping onto any one of the three would claim an equivalence false for the other two. Re-create the scaler from those blocks and paste the same mean and scale in

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

Description vs code#

The checker has a blind spot here — it could not resolve something (a grouped port bullet, a computed config name), which is reported and never counted as a pass. A reader has to settle it:

  • B0 every stimulus in the sample errored — cross-checks skipped

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

Standard Scaler — sklearn's StandardScaler, evaluated at inference, in both directions Standardize: y[i] = (u[i] - mean[i]) * inv[i] inv = 1 / scale Inverse: y[i] = u[i] * scale[i] + mean[i]

mean_ and scale_ are CONFIG COLUMNS, not a pickle loaded at run time: once a scaler is fitted they are just numbers, so the block is plain arithmetic that all ten export targets carry. See the header for why that decision is what makes this family verifiable at all, and for why the block has no state space and no Simulink bridge.

⚠ Unlike Dense_Layer, the three HDL targets here are REAL Q16.16 fixed point rather than simulation-only real: an affine map has no transcendental in it, so nothing forces the escape hatch. Keeping that property is exactly why Scale is inverted ONCE at config load and the datapath multiplies -- a per-sample divide is what would have cost it.

⚠ The reciprocal is also a CORRECTNESS device, not just an HDL one. compute_h() multiplies by the same precomputed inv[] the generators bake in, so the in-app run and all ten backends evaluate the identical expression. Dividing here and multiplying there would differ in the last ulp on every sample -- small, but it would be a real disagreement between the block and its own exported form, which is the one thing export verification exists to catch.

Sample results#

No stimulus produced a sampled output in this rig — Invalid input size at: ICore Blocks/Home/Standard Scaler. That is a fact about the single-block rig, not a verdict on the block: an offline batch fit, a block whose output only appears at onSolverFinish, or one that needs a driven environment cannot be exercised alone.

Category unsampled · sample time 0.1 · 60 steps · commit ccf005c8 · produced by docsSample --out <folder> --steps 60

Sample data: docs/generated/samples/Machine_Learning__Preprocessing__Standard_Scaler.json