Load dissimilarity matrix from a delimited text file or file path.
Creates a DissimilarityMatrix instance from a serialized dissimilarity matrix stored as delimited text.
dm_f can be a file-like or a file path object containing delimited text. The first line (header) must contain the IDs of each object. The subsequent lines must contain an ID followed by each dissimilarity (float) between the current object and all other objects, where the order of objects is determined by the header line. For example, a 2x2 dissimilarity matrix with IDs 'a' and 'b' might look like:
<del>a<del>b
a<del>0.0<del>1.0
b<del>1.0<del>0.0
where <del> is the delimiter between elements.
Parameters: | dm_f : iterable of str or str
delimiter : str, optional
|
---|---|
Returns: | DissimilarityMatrix
|
Notes
Whitespace-only lines can occur anywhere throughout the “file” and are ignored. Lines starting with # are treated as comments and ignored. These comments can only occur before the ID header.
IDs will have any leading/trailing whitespace removed when they are parsed.
Note
File-like objects passed to this method will not be closed upon the completion of the parsing, it is responsibility of the owner of the object to perform this operation.