Skip to main content
`Ctrl`+`K`

# skbio.stats.distance.PairwiseMatrix.from_iterable

classmethod PairwiseMatrix.from_iterable(iterable, metric, key=None, keys=None)

  Create a pairwise matrix from an iterable of objects given a metric.

  Parameters:
    iterable iterable

      Objects to compute pairwise relationships on.

    metric callable

      A function that takes two arguments and returns a float representing the relationship between the two objects.

    key callable or str, optional

      A function that takes one argument and returns a string representing the ID of the object. Alternatively, a key to the `metadata` property if exists for each object in the `iterable`. If None, the default IDs will be used.

    keys iterable of str, optional

      IDs of the objects. Must be the same length as `iterable`.

  Returns:
    PairwiseMatrix

      The `metric` applied to all pairwise elements in the `iterable`.

  Raises:
    ValueError

      If `key` and `keys` are both provided.