code: def test_batch_lof_scores():
      """
      Test that the incremental LOF algorithm returns similar LOF scores for each batch
      with `learn_many` compared with the original static LOF algorithm implemented in scikit-learn,
      under different batch sizes.
      """
      cc_df = pd.DataFrame(datasets.CreditCard())
      cc_df_np = [
          np.array(list(x.values()))
          for x in cc_df[0].to_dict().values()
      ]
  
      batch_sizes = [20, 50, 100]
  
      for batch_size in batch_sizes:
          ilof_river_batch = anomaly.LocalOutlierFactor(n_neighbors=20)
          ilof_river_batch.learn_many(cc_df[0:batch_size])
          ilof_scores_river_batch = np.array(
              [v for v in ilof_river_batch.lof.values()]
          )
  
          lof_sklearn_batch = neighbors.LocalOutlierFactor(
              n_neighbors=20
          )
          lof_sklearn_batch.fit_predict(cc_df_np[0:batch_size])
          lof_scores_sklearn_batch = (
              -lof_sklearn_batch.negative_outlier_factor_
          )
  
          assert np.allclose(
              ilof_scores_river_batch,
              lof_scores_sklearn_batch,
              rtol=1e-02,
              atol=1e-02,
          )
  
file_path: river/river/anomaly/test_lof.py
imports: from __future__ import annotations
  import numpy
  import pandas
  from sklearn import neighbors
  from river import anomaly, datasets
label_desc: Use image node_id 2 for calling a global function with example usage: test_batch_lof_scores() without return types