Main Content

Update performance metrics in naive Bayes classification model for incremental learning given new data and train model

Given streaming data, `updateMetricsAndFit`

first evaluates the performance of a configured naive Bayes classification model for incremental learning (`incrementalClassificationNaiveBayes`

object) by calling `updateMetrics`

on incoming data. Then `updateMetricsAndFit`

fits the model to that data by calling `fit`

. In other words, `updateMetricsAndFit`

performs *prequential evaluation* because it treats each incoming chunk of data as a test set, and tracks performance metrics measured cumulatively and over a specified window [1].

`updateMetricsAndFit`

provides a simple way to update model performance metrics and train the model on each chunk of data. Alternatively, you can perform the operations separately by calling `updateMetrics`

and then `fit`

, which allows for more flexibility (for example, you can decide whether you need to train the model based on its performance on a chunk of data).

returns a naive Bayes classification model for incremental learning `Mdl`

= updateMetricsAndFit(`Mdl`

,`X`

,`Y`

)`Mdl`

, which is the input naive Bayes classification model for incremental learning `Mdl`

with the following modifications:

`updateMetricsAndFit`

measures the model performance on the incoming predictor and response data,`X`

and`Y`

respectively. When the input model is*warm*(`Mdl.IsWarm`

is`true`

),`updateMetricsAndFit`

overwrites previously computed metrics, stored in the`Metrics`

property, with the new values. Otherwise,`updateMetricsAndFit`

stores`NaN`

values in`Metrics`

instead.`updateMetricsAndFit`

fits the modified model to the incoming data by updating the conditional posterior mean and standard deviation of each predictor variable, given the class, and stores the new estimates, among other configurations, in the output model`Mdl`

.

The input and output models have the same data type.