Skip to main content
Join the official 2019 Python Developers SurveyStart the survey!

Representation of persistence diagrams using persistence codebooks

Project description


Vectorization methods for persistence diagrams based in the paper Persistence Codebooks for Topological Data Analysis.


import perscode
import numpy as np

# generate diagrams
diagrams = [np.random.rand(100,2) for _ in range(20)]
for diagram in diagrams:
    diagram[:,1] += diagram[:,0]

# N is the size of the vectors
# normalize is a Bool to whether or not normalize the output vector
pbow = perscode.PBoW(N = 3, normalize = False)
wpbow = perscode.wPBoW(N = 3)
# n_subsample is an int or None. If none all points will be used when calculating GMMs.
spbow = perscode.sPBoW(N = 10, n_subsample = None)

# vectorize diagrams
pbow_diagrams  = pbow.transform(diagrams)
wpbow_diagrams = wpbow.transform(diagrams)
spbow_diagrams = spbow.transform(diagrams)

# for PVLAD and stable PVLAD
pvlad = perscode.PVLAD(N = 3)
spvlad = perscode.sPVLAD(N = 3)

pvlad_diagrams = pvlad.transform(diagrams)
spvlad_diagrams = spvlad.transform(diagrams)


  • [x] Implement options to pass cluster centers as arguments in wPBoW and sPBoW.
  • [x] Implement PVLAD
  • [x] Implement sPVLAD
  • [ ] Implement PFV
  • [x] Implement optional weighted subsampling to wPBoW, sPBoW, sPVLAD classes.

Project details

Release history Release notifications

This version


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for perscode, version 0.0.1
Filename, size File type Python version Upload date Hashes
Filename, size perscode-0.0.1-py3-none-any.whl (13.0 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size perscode-0.0.1.tar.gz (6.6 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page