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

Robust Scaler — Machine Learning/Preprocessing

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

Robust Scaler

Machine Learning / Preprocessing

Per-feature standardization on statistics that outliers do not move: y = (u − median) ÷ IQR, scikit-learn's RobustScaler at inference. IQR is the interquartile range, q75 − q25, which is scaler.scale_.

Reach for this instead of the Standard Scaler when the training data had outliers. A mean and a standard deviation are both pulled by a single extreme sample, so a scaler fitted through them squeezes the bulk of the data into a narrow band around zero; the median and the IQR are not pulled, so the features a model actually sees stay comparable. The two blocks are not interchangeable – a model expects the one it was trained behind.

Set Direction to Inverse for the other half of a deployed pipeline, y = u × IQR + median.

Ports

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

Parameters

  • Medianscaler.center_, an [m,1] column, one per feature. A zero column turns the block into a pure scaling, which is a scaler fitted with with_centering=False.
  • IQRscaler.scale_, an [m,1] column: the interquartile range of each feature. 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 whose quartiles coincide – such a feature is passed through centred rather than making the whole vector infinite.
  • Direction
    • Standardize – y = (u − median) ÷ IQR, the forward transform that feeds a model.
    • Inverse – y = u × IQR + median, which undoes it.
  • 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 statistics 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: IQR is inverted once when the configuration is loaded and the datapath multiplies by the reciprocal, so no divider is needed per sample. The same reciprocal is used by the block itself, so the exported core and the in-app run compute bit-identical values.

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, and y = C·x + D·u has nowhere to put the −median ÷ IQR offset.
  • The block does not compute a median or a quartile itself: it applies statistics that were already fitted, exactly as scikit-learn's transform does. Fitting happens where the training did.

Code facts#

FactValue
registered typeMachine_Learning/Preprocessing/Robust_Scaler
familyMachine_Learning/Preprocessing
solver environment classICoreBlock_0_Machine_Learning_1_Preprocessing_2_Robust_Scaler
sourcesrc/ICoreSDK/ICoreBlockLibrary/Blocks/Machine_Learning/Preprocessing/Robust_Scaler/ICoreBlock_0_Machine_Learning_1_Preprocessing_2_Robust_Scaler.cpp
headersrc/ICoreSDK/ICoreBlockLibrary/Blocks/Machine_Learning/Preprocessing/Robust_Scaler/ICoreBlock_0_Machine_Learning_1_Preprocessing_2_Robust_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
Median[0.3; -1.5; 4]
IQR[1.5; 0.4; 8]
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, and the DSP blocks that are installed (Normalization, the Moving statistics) compute their statistics from the running signal rather than applying fitted ones. Re-create the scaler from a Constant, a Sum and a Gain, and paste the same median and IQR 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).

Robust Scaler — sklearn's RobustScaler, evaluated at inference, in both directions Standardize: y = (u - median) * inv inv = 1 / IQR Inverse: y = u * IQR + median

Standard_Scaler's arithmetic with different STATISTICS, and the difference is the point: the mean and the standard deviation are both dragged by a single extreme sample, so a scaler fitted on outlier-heavy data squeezes the bulk of its range into a narrow band. The median and the interquartile range are not. A model trained behind one of these expects it.

Every decision here is inherited from Standard_Scaler deliberately -- see the header, and the Family G note "An affine block keeps SYNTHESIZABLE HDL" for why the reciprocal is taken once at config load rather than per sample, and why the block must multiply by the same constants its generators bake in.

Sample results#

No stimulus produced a sampled output in this rig — Invalid input size at: ICore Blocks/Home/Robust 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__Robust_Scaler.json