giotto-ai / giotto-tda

A high-performance topological machine learning toolbox in Python
https://giotto-ai.github.io/gtda-docs
Other
858 stars 175 forks source link

PairwiseDistance with bottleneck metric returns non-symmetric matrix when delta is not zero #397

Closed miltminz closed 4 years ago

miltminz commented 4 years ago

Test code:

from sklearn.datasets import load_digits
from gtda.homology import CubicalPersistence
from gtda.diagrams import PairwiseDistance

X, _ = load_digits(return_X_y=True) 
nb_samples = 100
CP = CubicalPersistence(homology_dimensions=(0, 1))
X_diag = CP.fit_transform(X[:nb_samples].reshape(nb_samples, 8, 8))
PD = PairwiseDistance(
    metric='bottleneck', metric_params={'delta': 0.01}, order=None)
X_distance = PD.fit_transform(X_diag)

The output returns, for example, X_distance[:, :, 0] which is not symmetric. As noticed by @ulupo in this discussion, the computation of the bottleneck distance is made by Hera and when delta is not zero the calculations are approximate and symmetry is not guaranteed.

The documentation of PairwiseDistance should include this explanation.