code: def test_river_vs_sklearn(model, sk_model, bag):
      """Assert that river Naive Bayes models and sklearn Naive Bayes models provide the same results
      when the input data are the same. Also check that the behaviour of Naives Bayes models are the
      same with dense and sparse dataframe. Models tested are MultinomialNB, BernoulliNB and
      ComplementNB with differents alpha parameters.
      """
      for x, y in yield_batch_dataset():
          model.learn_many(x, y)
  
      X = pd.concat([x for x, _ in yield_batch_dataset()])
      y = pd.concat([y for _, y in yield_batch_dataset()])
  
      sk_model = sk_model.fit(X=bag.transform_many(X), y=y)
  
      # Assert river produce same results as sklearn using sparse dataframe:
      for sk_preds, river_preds in zip(
          sk_model.predict_proba(bag.transform_many(X)),
          model.predict_proba_many(X).values,
      ):
          for sk_pred, river_pred in zip(sk_preds, river_preds):
              assert river_pred == pytest.approx(
                  1 - sk_pred
              ) or river_pred == pytest.approx(sk_pred)
  
      # Assert river produce same results as sklearn using dense dataframe:
      for sk_preds, river_preds in zip(
          sk_model.predict_proba(
              bag.transform_many(X).sparse.to_dense()
          ),
          model["model"]
          .predict_proba_many(bag.transform_many(X).sparse.to_dense())
          .values,
      ):
          for sk_pred, river_pred in zip(sk_preds, river_preds):
              assert river_pred == pytest.approx(
                  1 - sk_pred
              ) or river_pred == pytest.approx(sk_pred)
  
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 10 for calling a global function with example usage: test_river_vs_sklearn(model, sk_model, bag) without return types