submet
See my post with a brief algorithmic introduction for computing distances between pairs of subspaces.
submet
is a Python package for computing pairwise distances between equidimensional subspaces. All of these subspace metrics are dependent on the principle angles between the two subspaces. submet
implements an
sklearn-styled interface with a fitting method via a class called SubspaceDistance
, along with a variety of metrics in a class called Metric
.
import numpy as np
import submet
# generate random subspaces
s1 = np.random.rand((10, 2))
s2 = np.random.rand((10, 2))
# instantiate SubspaceDistance object, using the Grassmann distance metric
S = submet.subspaces.SubspaceDistance(metric='Grassmann')
# compute the distance between two subspaces
S.fit(s1, s2)
# print computed distance
print(S.distance_)
Metric
implements the following distance metrics:
- Asimov
- Binet-Cauchy
- Chordal
- Fubini-Study
- Martin
- Procrustes
- Projection
- Spectral
SubspaceDistance
does not currently support pairwise distance computations between more than a single pair of subspaces, in an analogous way to
Scipy’s
pdist or
cdist methods. I am working on allowing pairwise computations using
numba.
Update as of 6/30/2020: the above issue has been fixed and submet
now allows for pairwise distance matrix computations, rather than only single subspace pair comparisons. See this
pull request