Generated reference › Gradient Boosted Trees — Machine Learning/Classical Models
kind: generated#block#machine-learning-classical-models

Gradient Boosted Trees — Machine Learning/Classical Models

Machine_Learning/Classical_Models/Gradient_Boosted_Trees · 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.

Gradient Boosted Trees

Machine Learning / Classical Models

Evaluates an additive ensemble of regression trees:

score = base + rate · Σt leaft(u), then y = score or y = 1/(1 + e−score).

This is the inference half of XGBoost, LightGBM and sklearn's GradientBoosting – all three dump a model that reduces to exactly this. Boosting adds where a random forest averages, and that one difference is the only thing separating this block from Random Forest: they share the stacked node table, the leaf marker and the walker.

Ports

  • u – the feature column [d,1]. d is read off the largest Feature Index the tree table actually uses, so it needs no setting of its own.
  • y – a scalar [1,1]: the prediction, after whatever Output selects.

Parameters

  • Feature Index, Threshold, Left Child, Right Child, Leaf Value – the node table, one row per node, stacked across every tree, exactly as Decision Tree and Random Forest take it. A sample goes left when u[Feature Index] ≤ Threshold, which is scikit-learn's sense. A negative Left Child marks a leaf (TREE_LEAF), and at a leaf the feature and threshold are ignored, so tree_ pastes in unchanged.
  • Tree Roots – one row per tree, giving that tree's first node. Its length is the number of trees.
  • Base Score – the ensemble's starting prediction, before any tree. XGBoost calls it base_score; sklearn's initial estimator contributes it.
  • Learning Rate – the shrinkage applied to the tree sum. ⚠ Which exporter you came from decides this, and nothing in the numbers can tell you:
    • XGBoost and LightGBM bake the shrinkage into the leaf values when they dump a model, so leave this at 1.
    • sklearn's GradientBoosting keeps raw leaves and applies learning_rate at predict time – paste that value here.
    Getting it wrong is a silent constant factor across the whole prediction.
  • Output – the link applied to the score:
    • Raw (regression) – the score itself. The default.
    • Logistic (binary probability)1/(1 + e−s), which is what a binary classifier's margin means.
  • 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 ensemble is baked into the body: the traversal is emitted as a nested if cascade rather than a loop over the table, so each node appears exactly once, no index arithmetic exists anywhere, and the emitted code is O(nodes) rather than O(nodes×depth).

The two Output settings differ in hardware, and it is worth knowing which you are exporting. In Raw the block is comparisons, adds and one multiply – exact in every target and genuine synthesizable Q16.16 on the three HDLs. Logistic adds an exponential, so those three targets fall back to simulation-only real arithmetic for that setting, quantizing only at the port boundary.

Simulink bridge

None. Boosted-tree inference belongs to the Statistics and Machine Learning Toolbox, which is not installed here, and its interface takes a fitted model object rather than parameters – which no parameter rule could carry even if it were present. 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: the prediction depends only on the current sample.
  • Nonlinear and discontinuous, and deliberately carries no state space: the output steps at every split, so no A/B/C/D describes it and model reduction correctly refuses the block.
  • Children must have a higher row number than their parent, which every fitted exporter satisfies. It is checked, because a backward-pointing table would send the code emitter into unbounded recursion – a stack overflow at export time, far from the configuration that caused it.
  • The rate multiplies the SUM, not each leaf – the same number in exact arithmetic, and one multiply instead of one per tree.

Code facts#

FactValue
registered typeMachine_Learning/Classical_Models/Gradient_Boosted_Trees
familyMachine_Learning/Classical_Models
solver environment classICoreBlock_0_Machine_Learning_1_Classical_Models_2_Gradient_Boosted_Trees
sourcesrc/ICoreSDK/ICoreBlockLibrary/Blocks/Machine_Learning/Classical_Models/Gradient_Boosted_Trees/ICoreBlock_0_Machine_Learning_1_Classical_Models_2_Gradient_Boosted_Trees.cpp
headersrc/ICoreSDK/ICoreBlockLibrary/Blocks/Machine_Learning/Classical_Models/Gradient_Boosted_Trees/ICoreBlock_0_Machine_Learning_1_Classical_Models_2_Gradient_Boosted_Trees.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
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
Feature Index[0; -2; -2; 1; -2; -2]
Threshold[0; 0; 0; 0.2; 0; 0]
Left Child[1; -1; -1; 4; -1; -1]
Right Child[2; -1; -1; 5; -1; -1]
Leaf Value[0; 0.5; -0.4; 0; -0.3; 0.6]
Tree Roots[0; 3]
Base Score0
Learning Rate1
OutputRaw (regression)%~%Logistic (binary probability)~~Raw (re…

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 Simulink equivalent available here: boosted-tree inference belongs to the Statistics and Machine Learning Toolbox, which is not installed on this machine, and its interface takes a fitted MODEL OBJECT rather than parameters -- which no ParamRule could carry even if it were present. There is therefore no parameter set to map onto and no reference to run a parity testbench against

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

Gradient Boosted Trees — an ADDITIVE ensemble over Decision_Tree's stacked table score = base + rate * SUM_t leaf_t(u) y = score, or 1/(1 + exp(-score))

Random_Forest's block with one line changed: the accumulator adds instead of averaging, so there is no 1/T to fold. Everything else -- the stacked node columns, the leaf marker, the nested-if cascade, the left/right sense -- is Decision_Tree's, deliberately, so the three blocks cannot disagree about which way a sample falls at a split.

Sample results#

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