skbio.stats.distance.PairwiseMatrix.from_iterable#
- classmethod PairwiseMatrix.from_iterable(iterable, metric, key=None, keys=None)[source]#
Create a pairwise matrix from an iterable of objects given a metric.
- Parameters:
- iterableiterable
Objects to compute pairwise relationships on.
- metriccallable
A function that takes two arguments and returns a float representing the relationship between the two objects.
- keycallable or str, optional
A function that takes one argument and returns a string representing the ID of the object. Alternatively, a key to the
metadataproperty if exists for each object in theiterable. If None, the default IDs will be used.- keysiterable of str, optional
IDs of the objects. Must be the same length as
iterable.
- Returns:
- PairwiseMatrix
The
metricapplied to all pairwise elements in theiterable.
- Raises:
- ValueError
If
keyandkeysare both provided.