code: def test_evaluate_classifications_frames():
      dataset = foz.load_zoo_dataset("quickstart-video").clone()
  
      for sample in dataset:
          for frame in sample.frames.values():
              gt_idx = random.randint(0, _NUM_CLASSES - 1)
  
              logits = np.random.rand(_NUM_CLASSES)
              logits = np.log(logits / np.sum(logits))
              if random.random() < 0.8:
                  logits[gt_idx] = 0.0
  
              gt_label = _ANIMALS[gt_idx]
              pred_label = _ANIMALS[np.argmax(logits)]
  
              frame["gt_animal"] = fo.Classification(label=gt_label)
              frame["pred_animal"] = fo.Classification(
                  label=pred_label, logits=logits
              )
  
          sample.save()
  
      #
      # Simple classification
      #
  
      SIMPLE_EVAL_KEY = "eval_simple"
  
      results = dataset.evaluate_classifications(
          "frames.pred_animal",
          gt_field="frames.gt_animal",
          eval_key=SIMPLE_EVAL_KEY,
      )
  
      results.print_report()
  
      print(dataset.bounds(SIMPLE_EVAL_KEY))
      print(dataset.count_values("frames." + SIMPLE_EVAL_KEY))
      print(dataset.get_evaluation_info(SIMPLE_EVAL_KEY))
  
      #
      # Top-k classification
      #
  
      TOP_K_EVAL_KEY = "eval_top_k"
  
      top_k_results = dataset.evaluate_classifications(
          "frames.pred_animal",
          gt_field="frames.gt_animal",
          eval_key=TOP_K_EVAL_KEY,
          method="top-k",
          classes=_ANIMALS,
          k=2,
      )
  
      top_k_results.print_report()
  
      print(dataset.bounds(TOP_K_EVAL_KEY))
      print(dataset.count_values("frames." + TOP_K_EVAL_KEY))
      print(dataset.get_evaluation_info(TOP_K_EVAL_KEY))
  
      #
      # Binary classification
      #
  
      BINARY_EVAL_KEY = "eval_binary"
  
      binarize = (F("label") == "cat").if_else(F("label"), "other")
      binary_view = dataset.set_field(
          "frames.gt_animal.label", binarize
      ).set_field("frames.pred_animal.label", binarize)
  
      print(binary_view.count_values("frames.gt_animal.label"))
      print(binary_view.count_values("frames.pred_animal.label"))
  
      binary_results = binary_view.evaluate_classifications(
          "frames.pred_animal",
          gt_field="frames.gt_animal",
          eval_key=BINARY_EVAL_KEY,
          method="binary",
          classes=["other", "cat"],
      )
  
      binary_results.print_report()
  
      print(dataset.bounds(BINARY_EVAL_KEY))
      print(dataset.count_values("frames." + BINARY_EVAL_KEY))
      print(dataset.list_evaluations())
      print(dataset.get_evaluation_info(BINARY_EVAL_KEY))
  
      #
      # Cleanup
      #
  
      dataset.delete_evaluations()
  
file_path: fiftyone/tests/intensive/evaluation_tests.py
imports: import random
  import unittest
  import numpy
  import eta.core.utils
  import pytest
  import fiftyone
  import fiftyone.zoo
  from fiftyone import ViewField
label_desc: Use image node_id 4 for calling a global function with example usage: test_evaluate_classifications_frames() without return types