topo.eval
Submodules
Package Contents
Classes
RiemannMetric computes and stores the Riemannian metric and its dual |
Functions
|
Global score |
|
Global score |
|
|
|
Compute the geodesic distance matrix from an adjacency (or an affinity) matrix. |
|
|
|
- topo.eval.global_score_pca(X, Y, Y_pca=None)
Global score Input —— X: Instance matrix Y: Embedding
- topo.eval.global_score_laplacian(X, Y, k=10, data_is_graph=False, n_jobs=12, random_state=None)
Global score Input —— X: Instance matrix Y: Embedding
- topo.eval.knn_spearman_r(data_graph, embedding_graph, path_method='D', subsample_idx=None, unweighted=False, n_jobs=1)
- topo.eval.geodesic_distance(A, method='D', unweighted=False, directed=False, indices=None, n_jobs=-1, random_state=None)
Compute the geodesic distance matrix from an adjacency (or an affinity) matrix. The default behavior is to subset the geodesic distance matrix to only include distances up to the k-th nearest neighbor distance for each point. This is to ensure we are only assessing the performance of the embedding on the local structure of the data.
- Parameters:
A (array-like, shape (n_vertices, n_vertices)) – Adjacency or affinity matrix of a graph.
method (string, optional, default: 'D') – Method to compute the shortest path. - ‘D’: Dijkstra’s algorithm. - ‘FW’: Floyd-Warshall algorithm. - ‘B’: Bellman-Ford algorithm. - ‘J’: Johnson algorithm. - ‘F’: Floyd algorithm.
unweighted (bool, optional, default: False) – If True, the adjacency matrix is considered as unweighted.
directed (bool, optional, default: True) – If True, the adjacency matrix is considered as directed.
indices (array-like, shape (n_indices, ), optional, default: None) – Indices of the vertices to compute the geodesic distance matrix.
n_jobs (int, optional, default: 1) – The number of parallel jobs to use during search.
- Returns:
geodesic_distance (array-like, shape (n_vertices, n_vertices))
- topo.eval.geodesic_correlation(data, emb, landmarks=None, landmark_method='random', metric='euclidean', n_neighbors=3, n_jobs=-1, cor_method='spearman', random_state=None, return_graphs=False, verbose=False, **kwargs)
- class topo.eval.RiemannMetric(Y, L)
Bases:
object
RiemannMetric computes and stores the Riemannian metric and its dual associated with an embedding Y. The Riemannian metric is currently denoted by G, its dual by H, and the Laplacian by L. G at each point is the matrix inverse of H.
In the future, this class will be extended to compute H only once, for mdimY dimensions, but to store multiple G’s, with different dimensions. In the near future plans is also a “lazy” implementation, which will compute G (and maybe even H) only at the requested points.
This implementation is from megaman, by Marina Meila (License simplified BSD), with adaptations from Davi Sidarta-Oliveira as included in TopOMetry for performance and scikit-learn compability.
- Parameters:
Y (embedding coordinates, shape = (n, mdimY)) –
L (Laplacian matrix, shape = (n, n)) –
- Variables:
mdimG (dimension of G, H) –
mdimY (dimension of Y) –
H (dual Riemann metric, shape = (n, mdimY, mdimY)) –
G (Riemann metric, shape = (n, mdimG, mdimG)) –
Hvv ((transposed) singular vectors of H, shape = (n, mdimY, mdimY)) –
Hsvals (singular values of H, shape = (n, mdimY)) –
Gsvals (singular values of G, shape = (n, mdimG)) –
detG (determinants of G, shape = (n,1)) –
Notes
H is always computed at full dimension self.mdimY G is computed at mdimG (some contradictions persist here)
References
“Non-linear dimensionality reduction: Riemannian metric estimation and the problem of geometric discovery”, Dominique Perraul-Joncas, Marina Meila, arXiv:1305.7255
- get_dual_rmetric(invert_h=False)
Computes the dual Riemannian Metric.
- get_rmetric(return_svd=False)
Compute the Riemannian Metric
- get_mdimG()
- get_detG()
Gets the determinant of the Riemannian metric.
- fit(Y, L=None)
Fit the Riemannian Metric to a new embedding Y.
- transform(Y, L=None)
Here only for scikit-learn consistency. Calls the fit() method.
- topo.eval.get_eccentricity(emb, laplacian, H_emb=None)