Skip to main content

Python implementation persistent images representation of persistence diagrams.

Project description

PyPI version Build Status codecov License: MIT

Persim

Persim is a Python implementation of Persistence Images as first introduced in https://arxiv.org/abs/1507.06217.

It is designed to interface with Ripser, though any persistence diagram should work fine.

Setup

Currently, the only option is to install the library from source:

pip install persim

Usage

First, construct a diagram. In this example, we will use Ripser.

import numpy as np
from ripser import Rips
from sklearn import datasets

data = np.concatenate([150 * np.random.random((300,2)), 
                       10 + 10 * datasets.make_circles(n_samples=100)[0],
                       100 + 20 * datasets.make_circles(n_samples=100)[0]])

rips = Rips()
dgm = rips.fit_transform(data)
diagram = dgm[1] # Just diagram for H1

data and diagram

Then from this diagram, we construct the persistence image

from persim import PersImage

pim = PersImage()
img = pim.transform(diagram)
pim.show(img)

pers image of H1 diagram

Batch processing

If PersImage is given a list of diagrams, the dimensions will be the same for all resulting images. This is helpful if you want to process diagrams in batch and require them to be comparable.

diagrams = [rips.fit_transform(obs) for obs in observations]
imgs = pim.transform(diagrams)

References:

Persistence Images were first introduced in Adams et al, 2017. Much of this work, an examples contained herein are inspired by the work of Obayashi and Hiraoka, 2017. Choices of weightings and general methods are often derived from Kusano, Fukumizu, and Yasuaki Hiraoka, 2016.

Project details


Download files

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

Source Distribution

persim-0.0.6.tar.gz (5.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

persim-0.0.6-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

File details

Details for the file persim-0.0.6.tar.gz.

File metadata

  • Download URL: persim-0.0.6.tar.gz
  • Upload date:
  • Size: 5.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for persim-0.0.6.tar.gz
Algorithm Hash digest
SHA256 3de624d7762e5713eae22409effe40f804a49e1e67949ed3abe7c272bde6a17e
MD5 d48e8c1f4124eb4399149362b7de032f
BLAKE2b-256 fe0590ab4a38b5de8abfda9dc4f14d6c45a28bee28b0ddea0c1a39999f9cebf3

See more details on using hashes here.

File details

Details for the file persim-0.0.6-py3-none-any.whl.

File metadata

File hashes

Hashes for persim-0.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 b0e5321f520e3991e7a80dbaa2a94597e7bf6b83e7e22701105baaf44b3fbef1
MD5 f2128cccccdd533fc26f2d90b66d7576
BLAKE2b-256 3362b93d973f268b52e9e98e111387a7b587c48c79b3e6b7584c705232055a2f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page