API Documentation¶
Persistence¶
-
class
dowker_homology.persistence.
Persistence
(dimension=1, dissimilarity=None, additive_interleaving=0.0, multiplicative_interleaving=1.0, translation_function=None, truncation_method=None, restriction_method=None, resolution=0.0, n_samples=None, isolated_points=True, initial_point=0, coeff_field=11, max_simplex_size=200000.0, **kwargs)¶ This class is used for calculating and plotting persistent homology.
Parameters: - dimension (int (default : 1)) – Homology dimension to calculate.
- dissimilarity (str (default : 'dowker')) – The default assumes that the input is a dowker dissimilarity. Otherwise, any valid argument for the ‘metric’ of scipy.spatial.distance.cdist is is valid. To calculate the ambient Cech complex in Euclidean space, specify ‘ambient’.
- additive_interleaving (float (default : 0.0)) – Additive interleaving guarantee.
- multiplicative_interleaving (float (default : 1.0)) – Multiplicative interleaving guarantee.
- translation_function (function (default : None)) – Translation function. If not specified, the additive and multiplicative interleavings are used. If specified, overwrites additive and multiplicative interleavings.
- truncation_method (str (default : None)) – The truncation method used.
- restriction_method (str (default : None)) – The restriction method used
- resolution (float) –
- n_samples (int) –
- isolated_points (bool (default : True)) – Should isolated points be plotted in the persistence diagram?
- initial_point (int (default : 0)) –
- coef_field (int (default : 11)) – Characteristic p of the coefficient field Z/pZ for computing homology.
- max_simplex_size (int (default : 2e5)) – Maximal size of a simplex. Use to make sure that computation time is finite.
- **kwargs (dict, optional) – cutoff : int (default : 1) Cutoff for Graph dissimilarities. Additional arguments to the scipy.spatial.distance.cdist function.
-
persistent_homology
(X=None)¶ Computing persistent homology using gudhi.
Parameters: X (data) – Returns: dgms – One array for each dimension containing birth- and death values. Return type: list of ndarrays
-
plot_persistence
(X=None, plot_only=None, title=None, xy_range=None, labels=None, colormap='default', size=10, alpha=0.5, ax_color=array([0., 0., 0.]), colors=None, diagonal=True, lifetime=False, legend=True, show=False, return_plot=False)¶ Show or save persistence diagram
Parameters: - X (data) –
- plot_only (list of numeric) – If specified, an array of only the diagrams that should be plotted.
- title (string, default is None) – If title is defined, add it as title of the plot.
- xy_range (list of numeric [xmin, xmax, ymin, ymax]) – User provided range of axes. This is useful for comparing multiple persistence diagrams.
- labels (string or list of strings) – Legend labels for each diagram. If none are specified, we use H_0, H_1, H_2,… by default.
- colormap (str (default : 'default')) – Any of matplotlib color palettes. Some options are ‘default’, ‘seaborn’, ‘sequential’.
- size (numeric (default : 10)) – Pixel size of each point plotted.
- alpha (numeric (default : 0.5)) – Transparency of each point plotted.
- ax_color (any valid matplotlib color type.) – See https://matplotlib.org/api/colors_api.html for complete API.
- colors (list of colors) – color list for different homology dimensions
- diagonal (bool (default : True)) – Plot the diagonal x=y line.
- lifetime (bool (default : False) If True, diagonal is turned to False.) – Plot life time of each point instead of birth and death. Essentially, visualize (x, y-x).
- legend (bool (default : True)) – If true, show the legend.
- show (bool (default : False)) – Call plt.show() after plotting. If you are using self.plot() as part of a subplot, set show=False and call plt.show() only once at the end.
- return_plot (bool (default : False)) – Should plt be returned?
-
class
dowker_homology.persistence.
PersistenceTransformer
(dimension=1, dissimilarity=None, additive_interleaving=0.0, multiplicative_interleaving=1.0, translation_function=None, truncation_method=None, restriction_method=None, resolution=0.0, n_samples=None, isolated_points=True, initial_point=0, coeff_field=11, max_simplex_size=200000.0, **kwargs)¶ This class implements the fit and transform methods that are needed when calculating persistent homology in a sklearn-pipline.
Parameters: - dimension (int (default : 1)) – Homology dimension to calculate.
- dissimilarity (str (default : 'dowker')) – The default assumes that the input is a dowker dissimilarity. Otherwise, any valid argument for the ‘metric’ of scipy.spatial.distance.cdist is is valid. To calculate the ambient Cech complex in Euclidean space, specify ‘ambient’.
- additive_interleaving (float (default : 0.0)) – Additive interleaving guarantee.
- multiplicative_interleaving (float (default : 1.0)) – Multiplicative interleaving guarantee.
- translation_function (function (default : None)) – Translation function. If not specified, the additive and multiplicative interleavings are used. If specified, overwrites additive and multiplicative interleavings.
- truncation_method (str (default : None)) – The truncation method used.
- restriction_method (str (default : None)) – The restriction method used
- resolution (float) –
- n_samples (int) –
- isolated_points (bool (default : True)) – Should isolated points be plotted in the persistence diagram?
- initial_point (int (default : 0)) –
- coef_field (int (default : 11)) – Characteristic p of the coefficient field Z/pZ for computing homology.
- max_simplex_size (int (default : 2e5)) – Maximal size of a simplex. Use to make sure that computation time is finite.
- **kwargs (dict, optional) – cutoff : int (default : np.inf) Cutoff for Graph dissimilarities. Additional arguments to the scipy.spatial.distance.cdist function.
-
transform
(X, y=None)¶ Transform data into persistence diagrams.
Parameters: X (ndarray or list of ndarrays) – data Returns: dgms – One list for each dataset containing a list with an array for each dimension containing birth- and death values. Return type: list of list of ndarrays
Datasets¶
-
dowker_homology.datasets.
sphere
(N=400, dimension=2, factor=1, return_cover_radius=False)¶ Random points on a sphere.
Parameters: - N (int (default : 400)) – Number of points
- dimension (int (default : 2)) – Intrinsic dimension of the sphere
- factor (float (default : 1)) – Oversampling facto used to get more regular polytope.
- return_cover_radius (boolean (default : False)) – Return minimal distance between points.
-
dowker_homology.datasets.
regular_polygon
(N=100)¶ Regular polygon with N vertices
Parameters: N (int (default : 100)) – Number of points
-
dowker_homology.datasets.
clifford_torus
(N=100)¶ Spiral on the Clifford torus
Parameters: N (int (default : 100)) – Number of points
-
dowker_homology.datasets.
clifford_torus_grid
(N=100, dimension=2)¶ Regular grid of points on the Clifford torus.
Parameters: - N (int (default : 100)) – Number of points
- dimension (int (default : 2)) – Intrinsic dimension of the torus
-
dowker_homology.datasets.
regular_cubic_grid
(N=27, dimension=3, subdivisions=None, endpoint=True)¶ ” Regular cubical grid.
Parameters: - N (int (default : 27)) – Number of points
- dimension (int (default : 2)) – Dimension of the boundary of the cube
- subdivisions (int (default : None)) – Number of subdivisions of underlying intervals Overwrites N if specified
- endpoint (boolean (default : True)) – Include endpoints of intervals
-
dowker_homology.datasets.
regular_cube_boundary_grid
(dimension=2, subdivisions=2)¶ Regular grid on the boundary of a cube
Parameters: - dimension (int (default : 2)) – Dimension of the boundary of the cube
- subdivisions (int (default : 2)) – Number of subdivisions of underlying intervals