Add `mode` kwarg to KNeighborsGraph, refactor input-output formats in gtda.graphs, turn outputs of KNeighborsGraph and TransitionGraph into asymmetric adjacency matrices #478
Reference issues/PRs
Inspired by the discussion in #108, but only insofar as with this PR it would be possible to do IsoMap up until the distance matrix calculation (no embedding step).
Types of changes
[ ] Bug fix (non-breaking change which fixes an issue)
[x] New feature (non-breaking change which adds functionality)
[x] Breaking change (fix or feature that would cause existing functionality to change)
Description
Adds a mode kwarg to KNeighborsGraph so that, when it is set to 'distance', KNeighborsGraph and GraphGeodesicDistance together give all the steps in the IsoMap algorithm minus the embedding one.
Uses check_point_clouds consistently in gtda.graphs so that list input is now also accepted.
Avoids returning ragged 1D ndarray output, preferring lists instead, for consistency with other transformers returning collections of variable-size arrays.
The dtype of sparse matrices returned by KNeighborsGraph and TransitionGraph is now int (0-1 adjacency matrices).
The matrices returned by KNeighborsGraph and TransitionGraph are now not necessarily symmetric, meaning that:
A point j can be among the k-nearest neighbors of point i without the reverse being necessarily true
TransitionGraph now encodes the direction of time: entry ij is 1 only if j follows i in the time series (and not vice-versa).
The rationale for this is that a) GraphGeodesicDistance is unaffected because it has the option directed=False; b) VietorisRipsPersistence and FlagserPersistence work just fine with sparse asymmetric matrices.
Reference issues/PRs Inspired by the discussion in #108, but only insofar as with this PR it would be possible to do IsoMap up until the distance matrix calculation (no embedding step).
Types of changes
Description
mode
kwarg toKNeighborsGraph
so that, when it is set to'distance'
,KNeighborsGraph
andGraphGeodesicDistance
together give all the steps in the IsoMap algorithm minus the embedding one.check_point_clouds
consistently ingtda.graphs
so that list input is now also accepted.KNeighborsGraph
andTransitionGraph
is nowint
(0-1 adjacency matrices).KNeighborsGraph
andTransitionGraph
are now not necessarily symmetric, meaning that:TransitionGraph
now encodes the direction of time: entry ij is 1 only if j follows i in the time series (and not vice-versa).GraphGeodesicDistance
is unaffected because it has the optiondirected=False
; b)VietorisRipsPersistence
andFlagserPersistence
work just fine with sparse asymmetric matrices.Checklist
flake8
to check my Python changes.pytest
to check this on Python tests.