ComplexPolynomial¶
-
class
gtda.diagrams.
ComplexPolynomial
(n_coefficients=10, polynomial_type='R', n_jobs=None)[source]¶ Coefficients of complex polynomials whose roots are obtained from points in persistence diagrams.
Given a persistence diagram consisting of birth-death-dimension triples [b, d, q], subdiagrams corresponding to distinct homology dimensions are first considered separately. For each subdiagram, the polynomial whose roots are complex numbers obtained from its birth-death pairs is computed, and its
n_coefficients_
highest-degree complex coefficients excluding the top one are stored into a single real vector by concatenating the vector of all real parts with the vector of all imaginary parts 1 (if not enough coefficients are available to form a vector of the required length, padding with zeros is performed). Finally, all such vectors coming from different subdiagrams are concatenated to yield a single vector for the diagram.There are three possibilities for mapping birth-death pairs \((b, d)\) to complex polynomial roots. They are:
\begin{gather*} R(b, d) = b + \mathrm{i} d, \\ S(b, d) = \frac{d - b}{\sqrt{2} r} (b + \mathrm{i} d), \\ T(b, d) = \frac{d - b}{2} [\cos{r} - \sin{r} + \mathrm{i}(\cos{r} + \sin{r})], \end{gather*}where \(r = \sqrt{b^2 + d^2}\).
Important note:
Input collections of persistence diagrams for this transformer must satisfy certain requirements, see e.g.
fit
.
- Parameters
polynomial_type (
'R'
|'S'
|'T'
, optional, default:'R'
) – Type of complex polynomial to compute.n_coefficients (list, int or None, optional, default:
10
) – Number of complex coefficients per homology dimension. If an int then the number of coefficients will be equal to that value for each homology dimension. IfNone
then, for each homology dimension in the collection of persistence diagrams seen infit
, the number of complex coefficients is defined to be the largest number of off-diagonal points seen among all subdiagrams in that homology dimension, minus one.n_jobs (int or None, optional, default:
None
) – The number of jobs to use for the computation.None
means 1 unless in ajoblib.parallel_backend
context.-1
means using all processors.
-
n_coefficients_
¶ Effective number of complex coefficients per homology dimension. Set in
fit
.- Type
list
See also
References
- 1
B. Di Fabio and M. Ferri, “Comparing Persistence Diagrams Through Complex Vectors”; in Image Analysis and Processing — ICIAP 2015, 2015; `DOI: 10.1007/978-3-319-23231-7_27 <https://doi.org/10.1007/978-3-319-23231-7_27>_.
-
__init__
(n_coefficients=10, polynomial_type='R', n_jobs=None)[source]¶ Initialize self. See help(type(self)) for accurate signature.
-
fit
(X, y=None)[source]¶ Store all observed homology dimensions in
homology_dimensions_
and computen_coefficients_
. Then, return the estimator.This method is here to implement the usual scikit-learn API and hence work in pipelines.
- Parameters
X (ndarray of shape (n_samples, n_features, 3)) – Input data. Array of persistence diagrams, each a collection of triples [b, d, q] representing persistent topological features through their birth (b), death (d) and homology dimension (q). It is important that, for each possible homology dimension, the number of triples for which q equals that homology dimension is constants across the entries of X.
y (None) – There is no need for a target in a transformer, yet the pipeline API requires this parameter.
- Returns
self
- Return type
object
-
fit_transform
(X, y=None, **fit_params)¶ Fit to data, then transform it.
Fits transformer to X and y with optional parameters fit_params and returns a transformed version of X.
- Parameters
X (ndarray of shape (n_samples, n_features, 3)) – Input data. Array of persistence diagrams, each a collection of triples [b, d, q] representing persistent topological features through their birth (b), death (d) and homology dimension (q). It is important that, for each possible homology dimension, the number of triples for which q equals that homology dimension is constants across the entries of X.
y (None) – There is no need for a target in a transformer, yet the pipeline API requires this parameter.
- Returns
Xt – Polynomial coefficients: real and imaginary parts of the complex polynomials obtained in each homology dimension from each diagram in X.
- Return type
ndarray of shape (n_samples, n_homology_dimensions * 2 * n_coefficients_)
-
get_params
(deep=True)¶ Get parameters for this estimator.
- Parameters
deep (bool, default=True) – If True, will return the parameters for this estimator and contained subobjects that are estimators.
- Returns
params – Parameter names mapped to their values.
- Return type
mapping of string to any
-
set_params
(**params)¶ Set the parameters of this estimator.
The method works on simple estimators as well as on nested objects (such as pipelines). The latter have parameters of the form
<component>__<parameter>
so that it’s possible to update each component of a nested object.- Parameters
**params (dict) – Estimator parameters.
- Returns
self – Estimator instance.
- Return type
object
-
transform
(X, y=None)[source]¶ Compute vectors of real and imaginary parts of coefficients of complex polynomials obtained from each diagram in X.
- Parameters
X (ndarray of shape (n_samples, n_features, 3)) – Input data. Array of persistence diagrams, each a collection of triples [b, d, q] representing persistent topological features through their birth (b), death (d) and homology dimension (q). It is important that, for each possible homology dimension, the number of triples for which q equals that homology dimension is constants across the entries of X.
y (None) – There is no need for a target in a transformer, yet the pipeline API requires this parameter.
- Returns
Xt – Polynomial coefficients: real and imaginary parts of the complex polynomials obtained in each homology dimension from each diagram in X.
- Return type
ndarray of shape (n_samples, n_homology_dimensions * 2 * n_coefficients_)