code: def test_evaluate_classifications():
      dataset = foz.load_zoo_dataset("imagenet-sample").clone()
      logits_classes = dataset.default_classes
  
      model = foz.load_zoo_model("resnet50-imagenet-torch")
      dataset.take(25).apply_model(
          model, "predictions", store_logits=True
      )
  
      view = dataset.exists("predictions").set_field(
          "predictions.label",
          (F("confidence") > 0.9).if_else(F("label"), None),
      )
  
      # Restrict evaluation to 10 classes, for brevity
      classes = view.distinct("predictions.label")
      classes = classes[:9] + [_MISSING]
  
      #
      # Simple classification
      #
  
      SIMPLE_EVAL_KEY = "eval_simple"
  
      results = view.evaluate_classifications(
          "predictions",
          gt_field="ground_truth",
          eval_key=SIMPLE_EVAL_KEY,
          missing=_MISSING,
      )
  
      results.print_report()
      results.print_report(classes=classes)
  
      print(view.count_values(SIMPLE_EVAL_KEY))
      print(view.get_evaluation_info(SIMPLE_EVAL_KEY))
  
      #
      # Top-k classification
      #
  
      TOP_K_EVAL_KEY = "eval_top_k"
  
      top_k_results = view.evaluate_classifications(
          "predictions",
          gt_field="ground_truth",
          eval_key=TOP_K_EVAL_KEY,
          classes=logits_classes,
          missing=_MISSING,
          method="top-k",
          k=5,
      )
  
      top_k_results.print_report(classes=classes)
  
      print(view.count_values(TOP_K_EVAL_KEY))
      print(view.get_evaluation_info(TOP_K_EVAL_KEY))
  
      #
      # Binary classification
      #
  
      BINARY_EVAL_KEY = "eval_binary"
  
      neg_label = "other"
      pos_label = view.distinct("predictions.label")[0]
  
      binarize = (F("label") == pos_label).if_else(
          F("label"), neg_label
      )
      binary_view = view.set_field(
          "ground_truth.label", binarize
      ).set_field("predictions.label", binarize)
  
      print(binary_view.count_values("ground_truth.label"))
      print(binary_view.count_values("predictions.label"))
  
      binary_results = binary_view.evaluate_classifications(
          "predictions",
          gt_field="ground_truth",
          eval_key=BINARY_EVAL_KEY,
          method="binary",
          classes=[neg_label, pos_label],
      )
  
      binary_results.print_report()
  
      print(view.count_values(BINARY_EVAL_KEY))
      print(view.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 3 for calling a global function with example usage: test_evaluate_classifications() without return types