Generated reference › Multilabel Threshold — Machine Learning/Postprocessing
kind: generated#block#machine-learning-postprocessing

Multilabel Threshold — Machine Learning/Postprocessing

Machine_Learning/Postprocessing/Multilabel_Threshold · 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.

Multilabel Threshold

Machine Learning / Postprocessing

Applies a per-class operating point to a score vector, giving an indicator vector: yᵢ = 1 when uᵢ ≥ Thresholdsᵢ, and 0 otherwise.

This is the multi-label counterpart of Argmax Decision, which can only ever name one class. A multi-label model – which of these faults are present rather than which one fault is it – produces K independent scores, and each carries its own threshold because each has its own cost of being wrong: a class whose false alarms are expensive is given a higher one than a class whose misses are.

Ports

  • u – the score column, [K,1], one score per class. K is the number of entries in Thresholds, and the size is checked rather than broadcast. Scores need not be probabilities; any monotone score works, because the threshold is compared in the same units.
  • Outputy, [K,1], carrying 1 for each class whose score clears its threshold and 0 for each that does not. Any number of entries may be 1, including none and all – that is what makes it multi-label.

Parameters

  • Thresholds – a [K,1] column, one operating point per class, in the same units as the scores. The number of entries sets K.
  • Comparison – what happens to a score that lands exactly on its threshold.
    • Greater or equal (≥) – a score equal to its threshold counts as present. The default, and the convention scikit-learn's predict follows.
    • Strictly greater (>) – a score equal to its threshold counts as absent.
    This is worth setting deliberately rather than leaving: on the HDL targets a score arrives quantized to Q16.16, so a threshold that is exactly representable – 0.5, 0.25, 0.75 – is landed on exactly rather than approached, and the two conventions then disagree on real samples.
  • 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 thresholds are baked into the generated code as literals; there is no tunable parameter, because an operating point chosen against a validation set is not something to retune on the target.

Every target is exact rather than merely within tolerance, and the three HDL targets are genuinely synthesizable: the block compares and never multiplies, so nothing quantizes beyond the port boundary the signal already crossed.

Simulink bridge

None. 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 has no multi-label decision block either: a Compare To Constant applies ONE threshold to a whole signal, which is a different function whenever the thresholds differ from each other – and if they did not differ, this block would not be needed. Mapping onto it would assert an equivalence that holds only in the degenerate case. 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 sample.
  • Elementwise: class i's decision depends only on score i, so the block never compares classes against one another. That is exactly the difference from Argmax Decision, which ranks them.
  • No state space, deliberately. A threshold is a step function – not linear, and not differentiable at the operating point – so no A/B/C/D is true of it. Model reduction reports the block as unmergeable, which is the honest answer.
  • The output carries 1 and 0 as doubles, so it can drive arithmetic directly – multiply a cost vector by it to price the decision, or sum it to count how many classes fired.

Code facts#

FactValue
registered typeMachine_Learning/Postprocessing/Multilabel_Threshold
familyMachine_Learning/Postprocessing
solver environment classICoreBlock_0_Machine_Learning_1_Postprocessing_2_Multilabel_Threshold
sourcesrc/ICoreSDK/ICoreBlockLibrary/Blocks/Machine_Learning/Postprocessing/Multilabel_Threshold/ICoreBlock_0_Machine_Learning_1_Postprocessing_2_Multilabel_Threshold.cpp
headersrc/ICoreSDK/ICoreBlockLibrary/Blocks/Machine_Learning/Postprocessing/Multilabel_Threshold/ICoreBlock_0_Machine_Learning_1_Postprocessing_2_Multilabel_Threshold.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
Thresholds[0.5; -0.25; 0.8]
ComparisonGreater or equal (>=)%~%Strictly greater (>)~~Greater or …

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's Compare To Constant applies ONE threshold to a whole signal, which is a different function whenever the per-class thresholds differ -- and if they did not differ, this block would not be needed. Re-create it with a Constant carrying the threshold vector and a Relational Operator

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

Multilabel Threshold — a per-class operating point against a score vector y[i] = (u[i] >= Thresholds[i]) ? 1 : 0 (or > , as a mode)

The multi-label counterpart of Argmax_Decision, which can only ever name ONE class. Each class gets its OWN threshold, because each has its own cost of being wrong.

⚠ Comparison only, no arithmetic, so all ten targets are EXACT and the three HDL targets are genuinely synthesizable Q16.16 -- nothing is multiplied, so nothing quantizes. The same property Feature_Selector has, and for the same reason.

⚠ The boundary convention is a MODE, not a detail. A score landing exactly on its threshold is the only sample that distinguishes >= from >, and in fixed point that case is not rare: an HDL port delivers Q16.16, so a threshold that is representable exactly (0.5, 0.25) is hit exactly whenever the score quantizes onto it. Every backend must therefore agree on the boundary, which is why it is one config read once rather than an operator each generator chose for itself.

Sample results#

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