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

Max Abs Scaler — Machine Learning/Preprocessing

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

Max-Abs Scaler

Machine Learning / Preprocessing

Per-feature scaling by the largest magnitude seen while fitting, scikit-learn's MaxAbsScaler at inference: y = u ÷ max|x|. Each feature lands in [−1, 1].

Nothing is subtracted, and that is the point rather than a simplification:

  • Zero maps to zero, so a sparse feature vector stays sparse. The Standard and Min-Max scalers both destroy that – subtracting a mean or a data_min turns every stored zero into a nonzero – which is why this is the scaler scikit-learn documents for sparse data.
  • Signs are preserved, so a model that keyed on direction still sees it.

Ports

  • u – the feature column, [m,1], where m is the number of entries in Max Abs. The size is checked rather than broadcast.
  • Outputy, the same [m,1] shape.

Parameters

  • Max Absscaler.max_abs_, an [m,1] column: the largest absolute value each feature took while fitting. Entries are used as given; a zero entry is replaced by one, matching scikit-learn's own rule for a feature that was constantly zero, so it passes through untouched rather than making the whole vector infinite.
  • Direction
    • Standardize – y = u ÷ max|x|, the forward transform that feeds a model.
    • Inverse – y = u × max|x|, which recovers engineering units from a scaled value.
  • 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 per-feature factor is baked in as a literal at full precision.

The three HDL targets are genuine Q16.16 fixed point and synthesizable: Max Abs is inverted once when the configuration is loaded, so the datapath is a single multiply per feature and needs no divider. The same constant 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 – a Gain with the reciprocals pasted in is the whole of it, and mapping this block onto Gain would claim an equivalence that says nothing about where the constants came from. 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.

Notes

  • Algebraic and stateless.
  • No state space, and here the reason is not the usual one. A pure scale IS linear, so y = D·u could carry it – the block still declines, because letting model reduction merge it away would erase the sparsity and sign guarantee above from a diagram a user chose it for.
  • The three scalers are not interchangeable: Standard centres and divides by spread, Min-Max pins a fitted range onto a chosen interval, and this one scales by magnitude alone. A model expects the one it was trained behind.

Code facts#

FactValue
registered typeMachine_Learning/Preprocessing/Max_Abs_Scaler
familyMachine_Learning/Preprocessing
solver environment classICoreBlock_0_Machine_Learning_1_Preprocessing_2_Max_Abs_Scaler
sourcesrc/ICoreSDK/ICoreBlockLibrary/Blocks/Machine_Learning/Preprocessing/Max_Abs_Scaler/ICoreBlock_0_Machine_Learning_1_Preprocessing_2_Max_Abs_Scaler.cpp
headersrc/ICoreSDK/ICoreBlockLibrary/Blocks/Machine_Learning/Preprocessing/Max_Abs_Scaler/ICoreBlock_0_Machine_Learning_1_Preprocessing_2_Max_Abs_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
Max Abs[4; 0.5; 20]
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: a Gain carrying the reciprocals is the whole of it, and mapping onto Gain would assert an equivalence that says nothing about where the constants came from or that they must not be retuned on the target

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

Max-Abs Scaler — sklearn's MaxAbsScaler, evaluated at inference Standardize: y = u * inv inv = 1 / max|x| Inverse: y = u * max|x|

A PURE SCALE: nothing is subtracted in either direction, so zero maps to zero and every sign survives. That is the guarantee a user picks this scaler for -- see the header.

Both directions are one multiply by a per-feature constant, so _factor is resolved for the active direction at config load and every generator below is direction-agnostic. One code path instead of twenty, and the same trick Min_Max_Scaler uses for its inverse.

Sample results#

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