skbio.stats.distance.DistanceMatrix¶

class
skbio.stats.distance.
DistanceMatrix
(data, ids=None)[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.
See also
Notes
The distances are stored in redundant (squareform) format 1. To facilitate use with other scientific Python routines (e.g., scipy), the distances can be retrieved in condensed (vectorform) 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 (nonnegativity, identity of indiscernibles, and triangle inequality) 2. Thus, a DistanceMatrix instance can store distances that are not metric.
References
Attributes
T
Transpose of the dissimilarity matrix.
data
Array of dissimilarities.
default_write_format
dtype
Data type of the dissimilarities.
ids
Tuple of object IDs.
png
Display heatmap in IPython Notebook as PNG.
shape
Twoelement tuple containing the dissimilarity matrix dimensions.
size
Total number of elements in the dissimilarity matrix.
svg
Display heatmap in IPython Notebook as SVG.
Builtins
Check if the specified ID is in the dissimilarity matrix.
Compare this dissimilarity matrix to another for equality.
Slice into dissimilarity data by object ID or numpy indexing.
Determine whether two dissimilarity matrices are not equal.
Return a string representation of the dissimilarity matrix.
Methods
between
(from_, to_[, allow_overlap])Obtain the distances between the two groups of IDs
Return an array of distances in condensed format.
copy
()Return a deep copy of the dissimilarity matrix.
filter
(ids[, strict])Filter the dissimilarity matrix by IDs.
from_iterable
(iterable, metric[, key, keys, …])Create DistanceMatrix from all pairs in an iterable given a metric.
index
(lookup_id)Return the index of the specified ID.
permute
([condensed])Randomly permute both rows and columns in the matrix.
plot
([cmap, title])Creates a heatmap of the dissimilarity matrix
read
(file[, format])Create a new
DistanceMatrix
instance from a file.Return an array of dissimilarities in redundant format.
Create a
pandas.DataFrame
from thisDissimilarityMatrix
.Create a
pandas.Series
from thisDistanceMatrix
.Return the transpose of the dissimilarity matrix.
within
(ids)Obtain all the distances among the set of IDs
write
(file[, format])Write an instance of
DistanceMatrix
to a file.