Beispiel #1
0
 def compute_geom(self, diffusion_time, n_neighbors):
     data = self.data
     dim = self.dim
     #set radius according to paper (i think this is dim not d)
     radius = (diffusion_time * (diffusion_time * np.pi * 4)**(dim/2))**(0.5)
     #set adjacency radius large enough that points beyond it have affinity close to zero
     bigradius = 3 * radius
     adjacency_method = 'cyflann'
     cyflann_kwds = {'index_type':'kdtrees', 'num_trees':10, 'num_checks':n_neighbors}
     adjacency_kwds = {'radius':bigradius, 'cyflann_kwds':cyflann_kwds}
     affinity_method = 'gaussian'
     affinity_kwds = {'radius':radius}
     laplacian_method = 'geometric'
     laplacian_kwds = {'scaling_epps':radius}
     geom = Geometry(adjacency_method=adjacency_method, adjacency_kwds=adjacency_kwds,
                     affinity_method=affinity_method, affinity_kwds=affinity_kwds,
                     laplacian_method=laplacian_method, laplacian_kwds=laplacian_kwds)
     geom.set_data_matrix(data)
     adjacency_matrix = geom.compute_adjacency_matrix()
     laplacian_matrix = geom.compute_laplacian_matrix()
     return(geom)
Beispiel #2
0
adjacency_method = 'cyflann'
adjacency_kwds = {'radius': radius}
affinity_method = 'gaussian'
affinity_kwds = {'radius': radius}
laplacian_method = 'symmetricnormalized'
laplacian_kwds = {'scaling_epps': radius}
dataname = workingdirectory + '/untracked_data/chemistry_data/tolueneangles020619_pca50'
#dataname = '/Users/samsonkoelle/Downloads/manigrad-100818/mani-samk-gradients/untracked_data/chemistry_data/ethanolangles022119_pca50'
data = np.load(dataname + '.npy')
geom = Geometry(adjacency_method=adjacency_method,
                adjacency_kwds=adjacency_kwds,
                affinity_method=affinity_method,
                affinity_kwds=affinity_kwds,
                laplacian_method=laplacian_method,
                laplacian_kwds=laplacian_kwds)
geom.set_data_matrix(data)
geom.laplacian_method = 'geometric'
geom.laplacian_kwds = {'scaling_epps': radius}
laplacian_matrix = geom.compute_laplacian_matrix()
geom.compute_laplacian_matrix()
sample = np.arange(0, data.shape[0], 1000)
distorion_vs_rad_dim2 = run_estimate_radius(data,
                                            geom.adjacency_matrix,
                                            sample=sample,
                                            d=1,
                                            rmin=1,
                                            rmax=10,
                                            ntry=50,
                                            run_parallel=True,
                                            search_space='logspace')
np.save(dataname + '_distortionradius', distorion_vs_rad_dim2)
Beispiel #3
0
compute the Laplacian for best results you should use
laplacian_method = 'geometric' and set the keyword
parameter 'scaling_epps' to the 'radius' that was used
in the affinity method.

First import the class:
'''

from megaman.geometry.rmetric import RiemannMetric

'''
We can then estimate the R metric on each embedding with:
'''
geom.laplacian_method = 'geometric'
geom.laplacian_kwds = {'scaling_epps':radius} # scaling ensures convergence to Laplace-Beltrami operator
laplacian_matrix = geom.compute_laplacian_matrix()


rmetric_spectral = RiemannMetric(embed_spectral, geom.laplacian_matrix)
H_spectral = rmetric_spectral.get_dual_rmetric()

rmetric_ltsa = RiemannMetric(embed_ltsa, geom.laplacian_matrix)
H_ltsa = rmetric_ltsa.get_dual_rmetric()

rmetric_lle = RiemannMetric(embed_lle, geom.laplacian_matrix)
H_lle = rmetric_lle.get_dual_rmetric()

rmetric_isomap = RiemannMetric(embed_isomap, geom.laplacian_matrix)
H_isomap = rmetric_isomap.get_dual_rmetric()

'''