BettiCurve¶
- 
class gtda.diagrams.BettiCurve(n_bins=100, n_jobs=None)[source]¶
- Betti curves of persistence diagrams. - Given a persistence diagram consisting of birth-death-dimension triples [b, d, q], subdiagrams corresponding to distinct homology dimensions are considered separately, and their respective Betti curves are obtained by evenly sampling the filtration parameter. - Important note: - Input collections of persistence diagrams for this transformer must satisfy certain requirements, see e.g. - fit.
 - Parameters
- n_bins (int, optional, default: - 100) – The number of filtration parameter values, per available homology dimension, to sample during- fit.
- n_jobs (int or None, optional, default: - None) – The number of jobs to use for the computation.- Nonemeans 1 unless in a- joblib.parallel_backendcontext.- -1means using all processors.
 
 - 
samplings_¶
- For each number in homology_dimensions_, a discrete sampling of filtration parameters, calculated during - fitaccording to the minimum birth and maximum death values observed across all samples.- Type
- dict 
 
 - See also - PersistenceLandscape,- PersistenceEntropy,- HeatKernel,- Amplitude,- PairwiseDistance,- Silhouette,- PersistenceImage,- gtda.homology.VietorisRipsPersistence- Notes - The samplings in - samplings_are in general different between different homology dimensions. This means that the j-th entry of a Betti curve in homology dimension q typically arises from a different parameter values to the j-th entry of a curve in dimension q’.- 
__init__(n_bins=100, 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, for each dimension separately, store evenly sample filtration parameter values in- samplings_. 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 – Betti curves: one curve (represented as a one-dimensional array of integer values) per sample and per homology dimension seen in - fit. Index i along axis 1 corresponds to the i-th homology dimension in- homology_dimensions_.
- Return type
- ndarray of shape (n_samples, n_homology_dimensions, n_bins) 
 
 - 
fit_transform_plot(X, y=None, sample=0, **plot_params)¶
- Fit to data, then apply - transform_plot.- Parameters
- X (ndarray of shape (n_samples, ..)) – Input data. 
- y (ndarray of shape (n_samples,) or None) – Target values for supervised problems. 
- sample (int) – Sample to be plotted. 
- **plot_params – Optional plotting parameters. 
 
- Returns
- Xt – Transformed one-sample slice from the input. 
- Return type
- ndarray of shape (1, ..) 
 
 - 
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 
 
 - 
plot(Xt, sample=0, homology_dimensions=None, plotly_params=None)[source]¶
- Plot a sample from a collection of Betti curves arranged as in the output of - transform. Include homology in multiple dimensions.- Parameters
- Xt (ndarray of shape (n_samples, n_homology_dimensions, n_bins)) – Collection of Betti curves, such as returned by - transform.
- sample (int, optional, default: - 0) – Index of the sample in Xt to be plotted.
- homology_dimensions (list, tuple or None, optional, default: - None) – Which homology dimensions to include in the plot.- Nonemeans plotting all dimensions present in- homology_dimensions_.
- plotly_params (dict or None, optional, default: - None) – Custom parameters to configure the plotly figure. Allowed keys are- "traces"and- "layout", and the corresponding values should be dictionaries containing keyword arguments as would be fed to the- update_tracesand- update_layoutmethods of- plotly.graph_objects.Figure.
 
- Returns
- fig – Plotly figure. 
- Return type
- plotly.graph_objects.Figureobject
 
 - 
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 the Betti curves of diagrams 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 – Betti curves: one curve (represented as a one-dimensional array of integer values) per sample and per homology dimension seen in - fit. Index i along axis 1 corresponds to the i-th homology dimension in- homology_dimensions_.
- Return type
- ndarray of shape (n_samples, n_homology_dimensions, n_bins) 
 
 - 
transform_plot(X, sample=0, **plot_params)¶
- Take a one-sample slice from the input collection and transform it. Before returning the transformed object, plot the transformed sample. - Parameters
- X (ndarray of shape (n_samples, ..)) – Input data. 
- sample (int) – Sample to be plotted. 
- **plot_params – Optional plotting parameters. 
 
- Returns
- Xt – Transformed one-sample slice from the input. 
- Return type
- ndarray of shape (1, ..)