skbio.stats.distance.PairwiseMatrix.from_iterable#

classmethod PairwiseMatrix.from_iterable(iterable, metric, key=None, keys=None)[source]#

Create PairwiseMatrix from an iterable given a metric.

Parameters:
iterableiterable

Iterable containing objects to compute pairwise relationships on.

metriccallable

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

keycallable or metadata key, optional

A function that takes one argument and returns a string representing the id of the element in the pairwise matrix. Alternatively, a key to a metadata property if it exists for each element in the iterable. If None, then default ids will be used.

keysiterable, optional

An iterable of the same length as iterable. Each element will be used as the respective key.

Returns:
PairwiseMatrix

The metric applied to all pairwise elements in the iterable.

Raises:
ValueError

If key and keys are both provided.