class_docstr: Results from computing metrics.
class_docstr_tok: ["Results","from","computing","metrics","."]
docstr: Create rank-based metric results from the given rank/candidate sets.
code: def from_ranks(
      cls,
      metrics: Iterable[RankBasedMetric],
      rank_and_candidates: Iterable[RankPack],
  ) -> "RankBasedMetricResults":
      """Create rank-based metric results from the given rank/candidate sets."""
      return cls(
          data={
              RankBasedMetricKey(
                  side=pack.target,
                  rank_type=pack.rank_type,
                  metric=metric.key,
              ): metric(
                  ranks=pack.ranks,
                  num_candidates=pack.num_candidates,
                  weights=pack.weights,
              )
              for metric, pack in itertools.product(
                  metrics, rank_and_candidates
              )
          }
      )
  
imports: from __future__ import annotations
  import functools
  import itertools
  import logging
  import math
  import random
  import re
  from collections import defaultdict
  from typing import Callable, DefaultDict, Iterable, List, Mapping, MutableMapping, NamedTuple, Optional, Sequence, Tuple, Type, TypeVar, Union, cast
  import numpy
  import numpy.random
  import pandas
  import torch
  from class_resolver import HintOrType, OptionalKwargs
  from .evaluator import Evaluator, MetricResults, prepare_filter_triples
  from .ranks import Ranks
  from ..constants import COLUMN_LABELS, TARGET_TO_KEY_LABELS, TARGET_TO_KEYS
  from ..metrics.ranking import HITS_METRICS, RankBasedMetric, rank_based_metric_resolver
  from ..metrics.utils import Metric
  from ..triples.triples_factory import CoreTriplesFactory
  from ..typing import LABEL_HEAD, LABEL_TAIL, RANK_REALISTIC, RANK_TYPE_SYNONYMS, RANK_TYPES, SIDE_BOTH, SIDES, ExtendedTarget, MappedTriples, RankType, Target, normalize_rank_type, normalize_target
label_desc: Use image node_id 2 for calling the RankBasedMetricResults obj's underlying member method code with example usage: obj.from_ranks(cls, metrics, rank_and_candidates) and returns: cls