topo.utils.umap_utils

Module Contents

Functions

eval_gaussian(x[, pos, cov])

eval_density_at_point(x, embedding)

create_density_plot(X, Y, embedding)

torus_euclidean_grad(x, y[, torus_dimensions])

Standard euclidean distance.

fast_knn_indices(X, n_neighbors)

A fast computation of knn indices.

tau_rand_int(state)

A fast (pseudo)-random number generator.

tau_rand(state)

A fast (pseudo)-random number generator for floats in the range [0,1]

norm(vec)

Compute the (standard l2) norm of a vector.

submatrix(dmat, indices_col, n_neighbors)

Return a submatrix given an orginal matrix and the indices to keep.

ts()

csr_unique(matrix[, return_index, return_inverse, ...])

Find the unique elements of a sparse csr matrix.

topo.utils.umap_utils.eval_gaussian(x, pos=np.array([0, 0]), cov=np.eye(2, dtype=np.float32))
topo.utils.umap_utils.eval_density_at_point(x, embedding)
topo.utils.umap_utils.create_density_plot(X, Y, embedding)
topo.utils.umap_utils.torus_euclidean_grad(x, y, torus_dimensions=(2 * np.pi, 2 * np.pi))

Standard euclidean distance.

..math::

D(x, y) = sqrt{sum_i (x_i - y_i)^2}

topo.utils.umap_utils.fast_knn_indices(X, n_neighbors)

A fast computation of knn indices. :param X: The input data to compute the k-neighbor indices of. :type X: array of shape (n_samples, n_features) :param n_neighbors: The number of nearest neighbors to compute for each sample in X. :type n_neighbors: int

Returns:

knn_indices (array of shape (n_samples, n_neighbors)) – The indices on the n_neighbors closest points in the dataset.

topo.utils.umap_utils.tau_rand_int(state)

A fast (pseudo)-random number generator. :param state: The internal state of the rng :type state: array of int64, shape (3,)

Returns:

A (pseudo)-random int32 value

topo.utils.umap_utils.tau_rand(state)

A fast (pseudo)-random number generator for floats in the range [0,1] :param state: The internal state of the rng :type state: array of int64, shape (3,)

Returns:

A (pseudo)-random float32 in the interval [0, 1]

topo.utils.umap_utils.norm(vec)

Compute the (standard l2) norm of a vector. :param vec: :type vec: array of shape (dim,)

Returns:

The l2 norm of vec.

topo.utils.umap_utils.submatrix(dmat, indices_col, n_neighbors)

Return a submatrix given an orginal matrix and the indices to keep. :param dmat: Original matrix. :type dmat: array, shape (n_samples, n_samples) :param indices_col: Indices to keep. Each row consists of the indices of the columns. :type indices_col: array, shape (n_samples, n_neighbors) :param n_neighbors: Number of neighbors. :type n_neighbors: int

Returns:

submat (array, shape (n_samples, n_neighbors)) – The corresponding submatrix.

topo.utils.umap_utils.ts()
topo.utils.umap_utils.csr_unique(matrix, return_index=True, return_inverse=True, return_counts=True)

Find the unique elements of a sparse csr matrix. We don’t explicitly construct the unique matrix leaving that to the user who may not want to duplicate a massive array in memory. Returns the indices of the input array that give the unique values. Returns the indices of the unique array that reconstructs the input array. Returns the number of times each unique row appears in the input matrix. matrix: a csr matrix return_index = bool, optional

If true, return the row indices of ‘matrix’

return_inverse: bool, optional
If true, return the the indices of the unique array that can be

used to reconstruct ‘matrix’.

return_counts = bool, optional

If true, returns the number of times each unique item appears in ‘matrix’

The unique matrix can computed via unique_matrix = matrix[index] and the original matrix reconstructed via unique_matrix[inverse]