Calculate the Combinatorial Laplacian score of pixels on a nerve complex created by TDA mapper run on the MNIST dataset

library(RayleighSelection)

Load the mnist dataset

data("mnist")

Compute reduced representation

Using Laplacian eigenmap of pixels with high variance

library(dimRed)
leim <- LaplacianEigenmaps()
mnist_top <- mnist[apply(mnist, 1, var) > 10000,]
emb <- leim@fun(as(t(mnist_top), "dimRedData"), leim@stdpars)

Compute Mapper representation

Using the Laplacian eigenmap as an auxiliary function and correlation distance as metric

library(TDAmapper)
mnist_distances <- (1.0 - cor(mnist_top))
m2 <- mapper2D(distance_matrix = mnist_distances,
                filter_values = list(emb@data@data[,1], emb@data@data[,2]),
                num_intervals = c(30,30),
                percent_overlap = 35,
                num_bins_when_clustering = 10);

Compute the nerve complex

gg <- nerve_complex(m2$points_in_vertex)

Compute 0-form and 1-form Comb. Lap. scores, p-value, and q-value

For the 301st through 305th pixels

rayleigh_selection(gg, mnist[301:305,])


CamaraLab/RayleighSelection documentation built on Aug. 16, 2021, 12:01 p.m.