Generated reference › Incremental Classification Naive Bayes Predict — Machine Learning/Incremental Learning
kind: generated#block#machine-learning-incremental-learning

Incremental Classification Naive Bayes Predict — Machine Learning/Incremental Learning

NB predict

Machine_Learning/Incremental_Learning/Incremental_Classification_Naive_Bayes_Predict · 2 input / 3 output port(s) at insert · exports to Python, MATLAB, Java, Rust, C, C++

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.

Incremental Classification Naive Bayes Predict

Machine Learning / Incremental Learning

Classifies one observation per step with the Gaussian naive Bayes model an IncrementalClassificationNaiveBayes Fit block puts on its bus. The score of class k is its posterior probability,

scorek = Priork · ∏j N(xj; μkj, σkj) / Σc Priorc · ∏j N(xj; μcj, σcj),

where N is the normal density and a predictor whose σkj is 0 (a class seen at most once) is left out of class k's product, as Simulink's block does. The cost of class k is 1 − scorek, and the label is the class with the largest score. This is MATLAB's predict on an incrementalClassificationNaiveBayes learner, as Simulink's IncrementalClassificationNaiveBayes Predict block runs it.

Ports

  • mdl (ICoreBus) – the model, from an IncrementalClassificationNaiveBayes Fit block whose Class Names agree with this block's: DistrMean and DistrStd [K,P], Prior [K,1], CanPredict, IsWarm and MajorityClass. The run is refused when the bus is not that shape.
  • x – one observation of the P predictors, a row [1,P].
  • label – the predicted class, [1,1]: the entry of Class Names with the largest score, the first of a tie.
  • score – every class's posterior probability, a row [1,K] that sums to 1.
  • cost – every class's expected misclassification cost under MATLAB's default cost, 1 − score, a row [1,K].

Parameters

  • Class Names – the K class labels the Fit block was given, in the same order: a row or a column of distinct numbers, at least two. The label output is read from it.
  • Sampling Time (s) – zero or less inherits the solver's rate; a positive value runs the block at that period.

When a run is refused

x that is not a row, Class Names that are not distinct finite numbers, or a model bus whose shape is not the one K classes over P predictors give.

Code export

Six targets: Python, MATLAB, Java, Rust, C and C++, each reading the model's elements off the bus and computing the scores in the live block's order. The hardware targets (VHDL, Verilog, SystemVerilog) and PLC Structured Text carry no bus, so an export to one stops and names the block.

Simulink bridge

None (Support::None). Simulink's block takes its learner as InitialLearner, the name of an incrementalClassificationNaiveBayes object in the MATLAB workspace, which has no public constructor a generated script could write, so the bridge reports this block rather than dropping it, and it has no parity testbench. Code export verification covers it in the six targets above.

Notes

  • Algebraic and stateless: the model arrives on the bus every step.
  • A class whose Prior is 0 scores 0. Before the Fit block has fitted anything every Prior is 1/K, so the score is 1/K for every class and the label is the first class, as Simulink's is.
  • The product is taken as a sum of logarithms, normalized from its largest term, so scores whose densities would underflow come out as the shares they are rather than as 0/0; elsewhere it agrees with Simulink's to rounding. A NaN or infinite predictor is left out of every class's product.
  • Simulink's ScoreTransform, custom Prior and custom Cost options are not offered: the score is the posterior, and the cost is MATLAB's default.

Code facts#

FactValue
registered typeMachine_Learning/Incremental_Learning/Incremental_Classification_Naive_Bayes_Predict
familyMachine_Learning/Incremental_Learning
solver environment classICoreBlock_0_Machine_Learning_1_Incremental_Learning_2_Incremental_Classification_Naive_Bayes_Predict
sourcesrc/ICoreBlocks/ICoreBlockLibrary/Blocks/Machine_Learning/Incremental_Learning/Incremental_Classification_Naive_Bayes_Predict/ICoreBlock_0_Machine_Learning_1_Incremental_Learning_2_Incremental_Classification_Naive_Bayes_Predict.cpp
headersrc/ICoreBlocks/ICoreBlockLibrary/Blocks/Machine_Learning/Incremental_Learning/Incremental_Classification_Naive_Bayes_Predict/ICoreBlock_0_Machine_Learning_1_Incremental_Learning_2_Incremental_Classification_Naive_Bayes_Predict.h
default size on canvas160 × 90 px
ports at insert2 in, 3 out
code generators implementedPython, MATLAB, Java, Rust, C, C++

Ports#

#DirectionSignal typeDescription label
1inICoreBusmdl
2inICoreDoublex
3outICoreDoublelabel
4outICoreDoublescore
5outICoreDoublecost

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
Class Names[1 2 3]—

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): Simulink's IncrementalClassificationNaiveBayes Predict takes its learner as InitialLearner, the name of an incrementalClassificationNaiveBayes object in the MATLAB workspace, which has no public constructor a generated script could write; the block is reported rather than dropped

Catalog contract: src/ICoreBlocks/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).

IncrementalClassificationNaiveBayes Predict -- classify one observation from the model bus statsIncremental/Classification/NaiveBayes/IncrementalClassificationNaiveBayes Predict, MEASURED on R2026a 2026-10-02 (BLOCKS_TO_ADD_TOOLBOXES.md statsIncremental, on FEATURES_TO_ADD.md BF1). Two inputs, the Fit block's bus and x; Simulink's block shows the label alone by default and the score, cost and CanPredict behind checkboxes. Here the label, the score and the cost are the three outputs; CanPredict is on the bus already.

THE RULE, fitted to Simulink's block over 40 steps of a four-class run to 2.2e-16: score(k) = Prior(k) * PROD_j N(x_j; DistrMean(k,j), DistrStd(k,j)) / SUM over classes, where a predictor whose DistrStd(k,j) is 0 -- a class seen at most once, or never -- is LEFT OUT of class k's product rather than turning it into an impulse, and a class whose Prior is 0 scores 0. cost(k) = 1 - score(k) (MATLAB's default misclassification cost), and the label is Class Names at the FIRST largest score: with the prior [0.5 0.5 0 0] of two once-seen classes the score is that prior and the label is the first class.

The product is taken as a sum of logarithms and normalized from its largest term, so a run of tiny likelihoods comes out as the shares it is rather than as 0/0; Simulink's multiplies, and the two agree to rounding wherever Simulink's does not underflow. A non-finite predictor is left out of every class's product.

Sample results#

No stimulus produced a sampled output in this rig — Incorrect bus shape reaching port: ICore Blocks/Home/Incremental Classification Naive Bayes Predict/ICoreBus-In-0 requires { DistrMean: ICoreDouble [3x1], DistrStd: ICoreDouble [3x1], Prior: ICoreDouble [3x1], CanPredict: ICoreBool [1x1], IsWarm: ICoreBool [1x1], MajorityClass: ICoreUInt16 [1x1] }, ICore Blocks/Home/Bus Creator/ICoreBus-Out-0 carries { a: ICoreDouble [1x1], b: ICoreDouble [1x1] }. 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 ab8631aa8 · produced by docsSample --out <folder> --blocks Incremental_Classification_Naive_Bayes_Fit Incremental_Classification_Naive_Bayes_Predict --steps 60

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