Skip to content

Commit cf5bb38

Browse files
committed
Update README
1 parent e8e6a4f commit cf5bb38

File tree

1 file changed

+45
-3
lines changed

1 file changed

+45
-3
lines changed

README.rst

Lines changed: 45 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,45 @@ Euclidean distance representation.
3030
How to use PerVect
3131
------------------
3232

33-
The pervect library inheritis from sklearn classes and can be used as an sklearn
34-
transformer.
33+
The pervect library inherits from sklearn classes and can be used as an sklearn
34+
transformer. Assuming that you have a list persistence diagrams where each
35+
diagram is a numpy array of points in 2D then you can vectorize by simply applying:
3536

3637
.. code:: python
3738
3839
import pervect
3940
vects = pervect.PersistenceVectorizer().fit_transform(diagrams)
4041
4142
It can also be used in standard sklearn pipelines along with other machine learning
42-
tools including clustering and classifiers.
43+
tools including clustering and classifiers. For example, given a set of training
44+
diagrams, and a separate test set of diagrams we could do:
45+
46+
.. code:: python
47+
48+
import pervect
49+
vectorizer = pervect.PersistenceVectorizer().fit(train)
50+
train_vectors = vectorizer.transform(train)
51+
test_vectors = vectorizer.transform(test)
52+
53+
The vectorizer is also effective at efficiently approximating Wasserstein distance
54+
between diagrams. A trained model can compute pairwise Wasserstein distance between
55+
a list of diagrams as follows:
56+
57+
.. code:: python
58+
59+
import pervect
60+
vectorizer = pervect.PersistenceVectorizer().fit(train)
61+
test_diagram_distances = vectorizer.pairwise_p_wasserstein_distance(test, p=1)
62+
63+
The vectorizer can also automatically produce UMAP representations of the diagrams,
64+
either using "hellinger" distance or Wasserstein distance (note that transforming
65+
new data using Wassersteing trained UMAP is currently unavailable).
66+
67+
.. code:: python
68+
69+
import pervect
70+
diagram_map = pervect.PersistenceVectorizer(apply_umap=True).fit(diagrams)
71+
4372
4473
------------
4574
Installation
@@ -81,6 +110,19 @@ Install the package
81110
82111
pip install .
83112
113+
----------
114+
References
115+
----------
116+
117+
This package was inspired by and builds upon the work of Elizabeth Munch, Jose Perea,
118+
Firas Khasawneh and Sarah Tymochko. You can refer the the papers:
119+
120+
Jose A. Perea, Elizabeth Munch, Firas A. Khasawneh, *Approximating Continuous
121+
Functions on Persistence Diagrams Using Template Functions*, arXiv:1902.07190
122+
123+
Sarah Tymochko, Elizabeth Munch, Firas A. Khasawneh, *Adaptive Partitioning for
124+
Template Functions on Persistence Diagrams*, arXiv:1910.08506v1
125+
84126
-------
85127
License
86128
-------

0 commit comments

Comments
 (0)