code: def get_prediction_from_probabilities(
      classes: Union[List[int], List[str]],
      probabilities: List[float],
      prediction_method: str,
      random_state: int = 1234567890,
  ) -> Union[int, str]:
      """
      Convert a list of class-probabilities into a class prediction.
  
      If the prediction method is ``"expected_value"``, the class labels must be integers.
  
      Parameters
      ----------
      classes: Union[List[int], List[str]]
          List of string or integer class names.
      probabilities: List[float]
          List of probabilities for the respective classes.
      prediction_method: str
          Indicates how to get a single class prediction from the probabilities.
          Must be one of:
              1. ``"highest"``: Selects the class with the highest probability. If
                 multiple classes have the same probability, a class is selected randomly.
              2. ``"expected_value"``: Calculates an expected value over integer classes and
                 rounds to the nearest int.
      random_state: int, default=1234567890
          Seed for ``numpy.random.RandomState``, used for randomly selecting a class
          when necessary.
  
      Returns
      -------
      Union[int, str]
          The predicted class.
  
      Raises
      ------
      ValueError
          If ``classes`` does not contain integers and ``prediction_method`` is
          ``"expected_value"``.
  
      """
      prng = np.random.RandomState(random_state)
      if prediction_method == "highest":
          highest_p = max(probabilities)
          best_classes = [
              classes[i]
              for i, p in enumerate(probabilities)
              if p == highest_p
          ]
          if len(best_classes) > 1:
              ans = prng.choice(best_classes)
          else:
              ans = best_classes[0]
      elif prediction_method == "expected_value":
          exp_val = 0.0
          for class_, probability in zip(classes, probabilities):
              exp_val += class_ * probability  # type: ignore
          ans = int(round(exp_val))
  
      return ans
  
file_path: skll/skll/utils/commandline/compute_eval_from_predictions.py
imports: import argparse
  import csv
  import logging
  from pathlib import Path
  from typing import Dict, List, Optional, Union
  import numpy
  from skll.data import Reader, safe_float
  from skll.metrics import use_score_func
  from skll.types import PathOrStr
  from skll.version import __version__
label_desc: Use image node_id 1 for calling a global function with example usage: get_prediction_from_probabilities(classes, probabilities, prediction_method, random_state) and returns: ans