code: def relation_pattern_types(
      mapped_triples: Collection[Tuple[int, int, int]],
  ) -> pd.DataFrame:
      r"""
      Categorize relations based on patterns from RotatE [sun2019]_.
  
      The relation classifications are based upon checking whether the corresponding rules hold with sufficient support
      and confidence. By default, we do not require a minimum support, however, a relatively high confidence.
  
      The following four non-exclusive classes for relations are considered:
  
      - symmetry
      - anti-symmetry
      - inversion
      - composition
  
      This method generally follows the terminology of association rule mining. The patterns are expressed as
  
      .. math ::
  
          X_1 \land \cdot \land X_k \implies Y
  
      where $X_i$ is of the form $r_i(h_i, t_i)$, and some of the $h_i / t_i$ might re-occur in other atoms.
      The *support* of a pattern is the number of distinct instantiations of all variables for the left hand side.
      The *confidence* is the proportion of these instantiations where the right-hand side is also true.
  
      :param mapped_triples:
          A collection of ID-based triples.
      :returns:
          A dataframe of relation categorization
      """
      # determine patterns from triples
      base = iter_patterns(mapped_triples=mapped_triples)
  
      # drop zero-confidence
      base = (pattern for pattern in base if pattern.confidence > 0)
  
      # keep only skyline
      base = skyline(base)
  
      # create data frame
      return pd.DataFrame(
          data=list(base),
          columns=[
              RELATION_ID_COLUMN_NAME,
              PATTERN_TYPE_COLUMN_NAME,
              SUPPORT_COLUMN_NAME,
              CONFIDENCE_COLUMN_NAME,
          ],
      ).sort_values(
          by=[
              PATTERN_TYPE_COLUMN_NAME,
              RELATION_ID_COLUMN_NAME,
              CONFIDENCE_COLUMN_NAME,
              SUPPORT_COLUMN_NAME,
          ]
      )
  
imports: import hashlib
  import itertools
  import logging
  from collections import defaultdict
  from typing import Collection, DefaultDict, Iterable, Mapping, NamedTuple, Optional, Sequence, Set, Tuple, Union
  import numpy
  import pandas
  from tqdm.auto import tqdm
  from .None import TriplesFactory
  from ..constants import COLUMN_LABELS, TARGET_TO_INDEX
  from ..typing import COLUMN_HEAD, COLUMN_RELATION, COLUMN_TAIL, LABEL_HEAD, LABEL_RELATION, LABEL_TAIL, MappedTriples
label_desc: Use image node_id 21 for calling a global function with example usage: relation_pattern_types(mapped_triples) and returns: pd