tdads.kernel ============ .. py:module:: tdads.kernel Classes ------- .. autoapisummary:: tdads.kernel.kernel Module Contents --------------- .. py:class:: kernel(dim: int = 0, sigma: float = 1, t: float = 1, inf_replace_val: float = None, n_cores: int = cpu_count() - 1) .. py:method:: __str__() Describe a persistence Fisher kernel by its `sigma` and `t` parameters. .. py:method:: compute(D1, D2) Compute the kernel value between two persistence diagrams. :param `D1`: The first persistence diagram (computed from either the ripser, gph, flagser, gudhi or cechmate packages). :type `D1`: any :param `D2`: The second persistence diagram. :type `D2`: any :returns: The numeric kernel calculation value. :rtype: float .. rubric:: Examples >>> from tdads import kernel >>> from ripser import ripser >>> import numpy as np >>> # create 2 datasets >>> data1 = np.random((100,2)) >>> data2 = np.random((100,2)) >>> # compute persistence diagrams with ripser >>> diagram1 = ripser(data1) >>> diagram2 = ripser(data2) >>> # create kernel object >>> k = kernel() >>> # compute kernel value >>> k.compute(diagram1, diagrams2) Citations --------- Le T, Yamada M (2018). "Persistence fisher kernel: a riemannian manifold kernel for persistence diagrams." https://proceedings.neurips.cc/paper/2018/file/959ab9a0695c467e7caf75431a872e5c-Paper.pdf. .. py:method:: compute_matrix(diagrams, other_diagrams=None) Compute a Gram (kernel) matrix between one or two lists of persistence diagrams. :param `diagrams`: The first first of persistence diagram (computed from either the ripser, gph, flagser, gudhi or cechmate packages). :type `diagrams`: list :param `other_diagrams`: The optional second list of persistence diagram for computing a cross-Gram matrix. Default `None`. :type `other_diagrams`: any :returns: The (cross) Gram matrix. :rtype: numpy.ndarray .. rubric:: Examples >>> from tdads import kernel >>> from ripser import ripser >>> import numpy as np >>> # create 2 datasets >>> data1 = np.random((100,2)) >>> data2 = np.random((100,2)) >>> # compute persistence diagrams with ripser >>> diagram1 = ripser(data1) >>> diagram2 = ripser(data2) >>> # create kernel object >>> k = kernel() >>> # compute Gram matrix >>> k.compute_matrix([diagram1, diagram2]) >>> # this is the same as: >>> k.compute_matrix([diagram1, diagram2], [diagram1, diagram2])