skbio.core.distance.DistanceMatrix

class skbio.core.distance.DistanceMatrix(data, ids)[source]

Store distances between objects.

A DistanceMatrix is a DissimilarityMatrix with the additional requirement that the matrix data is symmetric. There are additional methods made available that take advantage of this symmetry.

Notes

The distances are stored in redundant (square-form) format [R13]. To facilitate use with other scientific Python routines (e.g., scipy), the distances can be retrieved in condensed (vector-form) format using condensed_form.

DistanceMatrix only requires that the distances it stores are symmetric. Checks are not performed to ensure the other three metric properties hold (non-negativity, identity of indiscernibles, and triangle inequality) [R14]. Thus, a DistanceMatrix instance can store distances that are not metric.

References

[R13](1, 2) http://docs.scipy.org/doc/scipy/reference/spatial.distance.html
[R14](1, 2) http://planetmath.org/metricspace

Attributes

T Transpose of the dissimilarity matrix.
data Array of dissimilarities.
dtype Data type of the dissimilarities.
ids Tuple of object IDs.
shape Two-element tuple containing the dissimilarity matrix dimensions.
size Total number of elements in the dissimilarity matrix.

Methods

__eq__(other) Compare this dissimilarity matrix to another for equality.
__getitem__(index) Slice into dissimilarity data by object ID or numpy indexing.
__ne__(other) Determine whether two dissimilarity matrices are not equal.
__str__() Return a string representation of the dissimilarity matrix.
condensed_form() Return an array of distances in condensed format.
copy() Return a deep copy of the dissimilarity matrix.
from_file(dm_f[, delimiter]) Load dissimilarity matrix from a delimited text file or file path.
redundant_form() Return an array of dissimilarities in redundant format.
to_file(out_f[, delimiter]) Save the dissimilarity matrix to file in delimited text format.
transpose() Return the transpose of the dissimilarity matrix.