Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DOCS] Clarify expected diagram properties to fix #233 #443

Merged
merged 2 commits into from
Aug 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions gtda/diagrams/distance.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ class PairwiseDistance(BaseEstimator, TransformerMixin):
matrices or a single distance matrix between pairs of diagrams is
calculated according to the following steps:

Input collections of persistence diagrams for this transformer must
satisfy certain requirements, see e.g. :meth:`fit`.

1. All diagrams are partitioned into subdiagrams corresponding to
distinct homology dimensions.
2. Pairwise distances between subdiagrams of equal homology
Expand Down Expand Up @@ -146,6 +149,9 @@ def fit(self, X, y=None):
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
Expand Down Expand Up @@ -190,6 +196,9 @@ def transform(self, X, y=None):
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
Expand Down
21 changes: 20 additions & 1 deletion gtda/diagrams/features.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ class PersistenceEntropy(BaseEstimator, TransformerMixin):
calculated as the (base e) entropies of the collections of differences
d - b, normalized by the sum of all such differences.

Input collections of persistence diagrams for this transformer must
satisfy certain requirements, see e.g. :meth:`fit`.

Parameters
----------
n_jobs : int or None, optional, default: ``None``
Expand All @@ -50,7 +53,8 @@ class PersistenceEntropy(BaseEstimator, TransformerMixin):
def __init__(self, n_jobs=None):
self.n_jobs = n_jobs

def _persistence_entropy(self, X):
@staticmethod
def _persistence_entropy(X):
X_lifespan = X[:, :, 1] - X[:, :, 0]
X_normalized = X_lifespan / np.sum(X_lifespan, axis=1).reshape(-1, 1)
return - np.sum(np.nan_to_num(
Expand All @@ -69,6 +73,9 @@ def fit(self, X, y=None):
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
Expand All @@ -95,6 +102,9 @@ def transform(self, X, y=None):
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
Expand Down Expand Up @@ -137,6 +147,9 @@ class Amplitude(BaseEstimator, TransformerMixin):
3. The final result is either :math:`\\mathbf{a}` itself or
a norm of :math:`\\mathbf{a}`, specified by the parameter `order`.

Input collections of persistence diagrams for this transformer must
satisfy certain requirements, see e.g. :meth:`fit`.

Parameters
----------
metric : ``'bottleneck'`` | ``'wasserstein'`` | ``'landscape'`` | \
Expand Down Expand Up @@ -242,6 +255,9 @@ def fit(self, X, y=None):
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
Expand Down Expand Up @@ -284,6 +300,9 @@ def transform(self, X, y=None):
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
Expand Down
15 changes: 12 additions & 3 deletions gtda/diagrams/preprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,9 @@ class Scaler(BaseEstimator, TransformerMixin, PlotterMixin):
two-dimensional array of amplitudes (one per diagram and homology
dimension) to obtain :attr:`scale_`.

Input collections of persistence diagrams for this transformer must
satisfy certain requirements, see e.g. :meth:`fit`.

Parameters
----------
metric : ``'bottleneck'`` | ``'wasserstein'`` | ``'betti'`` | \
Expand Down Expand Up @@ -196,6 +199,9 @@ def fit(self, X, y=None):
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
Expand Down Expand Up @@ -244,6 +250,9 @@ def transform(self, X, y=None):
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
Expand All @@ -262,13 +271,13 @@ def transform(self, X, y=None):
return Xs

def inverse_transform(self, X):
"""Scale back the data to the original representation. Multiplies
by the scale found in :meth:`fit`.
"""Scale back the data to the original representation. Multiplies by
the scale found in :meth:`fit`.

Parameters
----------
X : ndarray of shape (n_samples, n_features, 3)
Data to apply the inverse transform to.
Data to apply the inverse transform to, c.f. :meth:`transform`.

Returns
-------
Expand Down
45 changes: 45 additions & 0 deletions gtda/diagrams/representations.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ class BettiCurve(BaseEstimator, TransformerMixin, PlotterMixin):
considered separately, and their respective Betti curves are obtained by
evenly sampling the :ref:`filtration parameter <filtered_complex>`.

Input collections of persistence diagrams for this transformer must
satisfy certain requirements, see e.g. :meth:`fit`.

Parameters
----------
n_bins : int, optional, default: ``100``
Expand Down Expand Up @@ -93,6 +96,9 @@ def fit(self, X, y=None):
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
Expand Down Expand Up @@ -124,6 +130,9 @@ def transform(self, X, y=None):
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
Expand Down Expand Up @@ -238,6 +247,9 @@ class PersistenceLandscape(BaseEstimator, TransformerMixin, PlotterMixin):
landscapes are obtained by evenly sampling the :ref:`filtration parameter
<filtered_complex>`.

Input collections of persistence diagrams for this transformer must
satisfy certain requirements, see e.g. :meth:`fit`.

Parameters
----------
n_layers : int, optional, default: ``1``
Expand Down Expand Up @@ -302,6 +314,9 @@ def fit(self, X, y=None):
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
Expand Down Expand Up @@ -333,6 +348,9 @@ def transform(self, X, y=None):
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
Expand Down Expand Up @@ -462,6 +480,9 @@ class HeatKernel(BaseEstimator, TransformerMixin, PlotterMixin):
diagonal, and the difference between the results of the two convolutions is
computed. The result can be thought of as a (multi-channel) raster image.

Input collections of persistence diagrams for this transformer must
satisfy certain requirements, see e.g. :meth:`fit`.

Parameters
----------
sigma : float, optional default ``1.``
Expand Down Expand Up @@ -534,6 +555,9 @@ def fit(self, X, y=None):
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
Expand Down Expand Up @@ -567,6 +591,9 @@ def transform(self, X, y=None):
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
Expand Down Expand Up @@ -642,6 +669,9 @@ class PersistenceImage(BaseEstimator, TransformerMixin, PlotterMixin):
<filtered_complex>`. The result can be thought of as a (multi-channel)
raster image.

Input collections of persistence diagrams for this transformer must
satisfy certain requirements, see e.g. :meth:`fit`.

Parameters
----------
sigma : float, optional default ``1.``
Expand Down Expand Up @@ -731,6 +761,9 @@ def fit(self, X, y=None):
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
Expand Down Expand Up @@ -771,6 +804,9 @@ def transform(self, X, y=None):
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
Expand Down Expand Up @@ -850,6 +886,9 @@ class Silhouette(BaseEstimator, TransformerMixin, PlotterMixin):
spaced locations from appropriate ranges of the :ref:`filtration parameter
<filtered_complex>`.

Input collections of persistence diagrams for this transformer must
satisfy certain requirements, see e.g. :meth:`fit`.

Parameters
----------
power: float, optional, default: ``1.``
Expand Down Expand Up @@ -923,6 +962,9 @@ def fit(self, X, y=None):
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
Expand Down Expand Up @@ -954,6 +996,9 @@ def transform(self, X, y=None):
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
Expand Down