code: def test_learn_many_vs_learn_one(model, batch_model):
      """Assert that the Naive Bayes river models provide the same results when learning in
      incremental and mini-batch modes. The models tested are MultinomialNB, BernoulliNB and
      ComplementNB with differents alpha parameters..
      """
      for x, y in yield_dataset():
          model.learn_one(x, y)
  
      for x, y in yield_batch_dataset():
          batch_model.learn_many(x, y)
  
      assert model["model"].p_class("yes") == batch_model[
          "model"
      ].p_class("yes")
      assert model["model"].p_class("no") == batch_model[
          "model"
      ].p_class("no")
  
      # Assert batch and incremental models give same results
      for x, x_batch in zip(
          yield_unseen_data(), yield_batch_unseen_data()
      ):
          assert model.predict_proba_one(x)["yes"] == pytest.approx(
              batch_model.predict_proba_many(x_batch)["yes"][0]
          )
  
          assert model.predict_proba_one(x)["no"] == pytest.approx(
              batch_model.predict_proba_many(x_batch)["no"][0]
          )
  
      # Assert class probabilities are the same when trainig Naive Bayes in pure online and in batch.
      assert model["model"].p_class("yes") == batch_model[
          "model"
      ].p_class("yes")
      assert model["model"].p_class("no") == batch_model[
          "model"
      ].p_class("no")
  
      # Assert conditionnal probabilities are the same when training Naive Bayes in pure online and
      # in batch.
      if isinstance(
          model["model"], naive_bayes.BernoulliNB
      ) or isinstance(model["model"], naive_bayes.MultinomialNB):
          inc_cp = model["model"].p_feature_given_class
          batch_cp = batch_model["model"].p_feature_given_class
  
          assert inc_cp("Chinese", "yes") == batch_cp("Chinese", "yes")
          assert inc_cp("Tokyo", "yes") == batch_cp("Tokyo", "yes")
          assert inc_cp("Japan", "yes") == batch_cp("Japan", "yes")
          assert inc_cp("Chinese", "no") == batch_cp("Chinese", "no")
          assert inc_cp("Tokyo", "no") == batch_cp("Tokyo", "no")
          assert inc_cp("Japan", "no") == batch_cp("Japan", "no")
          assert inc_cp("unseen", "yes") == batch_cp("unseen", "yes")
  
      assert (
          model["model"].class_counts
          == batch_model["model"].class_counts
      )
      assert (
          model["model"].feature_counts
          == batch_model["model"].feature_counts
      )
  
      if isinstance(
          model["model"], naive_bayes.ComplementNB
      ) or isinstance(model["model"], naive_bayes.MultinomialNB):
          assert (
              model["model"].class_totals
              == batch_model["model"].class_totals
          )
  
      if isinstance(model["model"], sk_naive_bayes.ComplementNB):
          assert (
              model["model"].feature_totals
              == batch_model["model"].feature_totals
          )
  
file_path: river/river/naive_bayes/test_naive_bayes.py
imports: from __future__ import annotations
  import pandas
  import pytest
  from sklearn import naive_bayes
  from river import compose, feature_extraction, naive_bayes
label_desc: Use image node_id 8 for calling a global function with example usage: test_learn_many_vs_learn_one(model, batch_model) without return types