Vectorization

org.appliedtopology.tda4j.Vectorization
object Vectorization

Fixed-size arrays of numbers from a barcode, for statistics and machine learning: persistence landscapes (Bubenik 2013), persistence images (Adams et al. 2017), Betti curves, persistence silhouettes (Chazal et al. 2014) and persistence entropy (Rucco et al. 2016).

Essential bars count in landscape (their tent is the ramp t - birth, finite on any grid) and in bettiCurve (alive from their birth on); persistenceImage, silhouette and persistenceEntropy drop them (a Gaussian, a weight or a share of the total length at infinite persistence is not a number).

Attributes

Experimental
true
Source
Vectorization.scala
Graph
Supertypes
class Object
trait Matchable
class Any
Self type

Members list

Value members

Concrete methods

def bettiCurve(diagram: Seq[PersistenceBar[Double, _]], tMin: Double, tMax: Double, resolution: Int): Array[Int]

The Betti curve of diagram: the number of bars alive at each of resolution evenly-spaced points of [tMin, tMax] (both ends included). A bar [birth, death) is alive at t when birth <= t < death, so a bar that ends exactly at a sample is already gone there; an essential bar is alive from its birth on. The curve of one degree is Vectorization.bettiCurve(diagram.dim(k).bars, ...); of a whole diagram, the total number of alive bars.

The Betti curve of diagram: the number of bars alive at each of resolution evenly-spaced points of [tMin, tMax] (both ends included). A bar [birth, death) is alive at t when birth <= t < death, so a bar that ends exactly at a sample is already gone there; an essential bar is alive from its birth on. The curve of one degree is Vectorization.bettiCurve(diagram.dim(k).bars, ...); of a whole diagram, the total number of alive bars.

Attributes

Source
Vectorization.scala
def landscape(diagram: Seq[PersistenceBar[Double, _]], numLevels: Int, tMin: Double, tMax: Double, resolution: Int): Array[Array[Double]]

Samples the first numLevels persistence landscape functions of diagram (Bubenik 2013) on resolution evenly-spaced points across [tMin, tMax] (inclusive of both ends). Returns levels(k)(j), k from 0 (the outer envelope, i.e. the pointwise max over all bars' tent functions) to numLevels - 1, j from 0 to resolution - 1 at t_j = tMin + j * (tMax - tMin) / (resolution - 1). A t with fewer than numLevels bars alive gets 0 for the missing levels, the standard "k-th order statistic of a smaller set is 0" convention.

Samples the first numLevels persistence landscape functions of diagram (Bubenik 2013) on resolution evenly-spaced points across [tMin, tMax] (inclusive of both ends). Returns levels(k)(j), k from 0 (the outer envelope, i.e. the pointwise max over all bars' tent functions) to numLevels - 1, j from 0 to resolution - 1 at t_j = tMin + j * (tMax - tMin) / (resolution - 1). A t with fewer than numLevels bars alive gets 0 for the missing levels, the standard "k-th order statistic of a smaller set is 0" convention.

'''Closed-form check''' (used by the test suite as an exact oracle, not just eyeballing plots): integrating every level and summing gives sum_i (death_i - birth_i)^2 / 4 exactly, for a [tMin, tMax] containing every finite bar's support -- each bar's tent function has triangular area persistence * (persistence/2) / 2, and sum_k integral(level_k) = sum_i integral(tent_i) because integration is linear and, at each fixed t, the multiset of order statistics {level_k(t)} is exactly the multiset {tent_i(t)} reordered.

Attributes

Source
Vectorization.scala
def persistenceEntropy(diagram: Seq[PersistenceBar[Double, _]], normalized: Boolean = ...): Double

The persistence entropy of diagram (Rucco, Castiglione, Merelli, Pettini 2016): with l_i the persistence of finite bar i and p_i = l_i / sum l, the Shannon entropy -sum p_i ln p_i. It is 0 for one bar and ln n for n bars of equal length, so a diagram dominated by a few long bars scores low and one made of many bars of similar length scores high. With normalized, divided by ln n (the largest value for n bars), so it lies in [0, 1]; a diagram with fewer than two finite bars of positive length has entropy 0. Essential bars are dropped.

The persistence entropy of diagram (Rucco, Castiglione, Merelli, Pettini 2016): with l_i the persistence of finite bar i and p_i = l_i / sum l, the Shannon entropy -sum p_i ln p_i. It is 0 for one bar and ln n for n bars of equal length, so a diagram dominated by a few long bars scores low and one made of many bars of similar length scores high. With normalized, divided by ln n (the largest value for n bars), so it lies in [0, 1]; a diagram with fewer than two finite bars of positive length has entropy 0. Essential bars are dropped.

Attributes

Source
Vectorization.scala
def persistenceImage(diagram: Seq[PersistenceBar[Double, _]], sigma: Double, birthRange: (Double, Double), persistenceRange: (Double, Double), birthResolution: Int, persistenceResolution: Int, weightCap: Optional[Double] = ...): Array[Array[Double]]

The persistence image (Adams et al. 2017) of diagram. Each finite bar becomes the point (birth, death - birth), then a Gaussian of standard deviation sigma weighted by piecewiseLinearWeight of its persistence (weightCap defaults to the largest finite persistence). Each pixel holds the exact integral of the surface over the pixel, as in persim.

The persistence image (Adams et al. 2017) of diagram. Each finite bar becomes the point (birth, death - birth), then a Gaussian of standard deviation sigma weighted by piecewiseLinearWeight of its persistence (weightCap defaults to the largest finite persistence). Each pixel holds the exact integral of the surface over the pixel, as in persim.

Returns image(r)(c): r indexes birthResolution pixels spanning birthRange, c indexes persistenceResolution pixels spanning persistenceRange. Essential bars are dropped.

Attributes

Source
Vectorization.scala
def silhouette(diagram: Seq[PersistenceBar[Double, _]], tMin: Double, tMax: Double, resolution: Int, power: Double = ...): Array[Double]

The persistence silhouette of diagram (Chazal, Fasy, Lecci, Rinaldo, Wasserman 2014): at each of resolution evenly-spaced points of [tMin, tMax], the average of the bars' tent functions (the ones landscape takes the order statistics of), each weighted by its persistence to the power power. power = 1.0 (the default) weights long bars more than short ones; a small power approaches the plain average of the tents, a large one the outline of the longest bar. Essential bars are dropped. An empty diagram has the zero silhouette.

The persistence silhouette of diagram (Chazal, Fasy, Lecci, Rinaldo, Wasserman 2014): at each of resolution evenly-spaced points of [tMin, tMax], the average of the bars' tent functions (the ones landscape takes the order statistics of), each weighted by its persistence to the power power. power = 1.0 (the default) weights long bars more than short ones; a small power approaches the plain average of the tents, a large one the outline of the longest bar. Essential bars are dropped. An empty diagram has the zero silhouette.

Attributes

Source
Vectorization.scala