(dist_matrix)
return averages
Calculate the average distance to each points nearest neighbors.

    Parameters
    ----------
    dist_matrix: a csr_matrix
        A distance matrix (usually umap_model.graph_)

    Returns
    -------
    An array with the average distance to each points nearest neighbors
Calculate the average distance to each points nearest neighbors.
Calculate the average distance to each points nearest neighbors .
def average_nn_distance(dist_matrix):
    """Calculate the average distance to each points nearest neighbors.

    Parameters
    ----------
    dist_matrix: a csr_matrix
        A distance matrix (usually umap_model.graph_)

    Returns
    -------
    An array with the average distance to each points nearest neighbors

    """
    (row_idx, col_idx, val) = scipy.sparse.find(dist_matrix)

    # Count/sum is done per row
    count_non_zero_elems = np.bincount(row_idx)
    sum_non_zero_elems = np.bincount(row_idx, weights=val)
    averages = sum_non_zero_elems / count_non_zero_elems

    if any(np.isnan(averages)):
        warn(
            "Embedding contains disconnected vertices which will be ignored."
            "Use umap.utils.disconnected_vertices() to identify them."
        )

    return averages
def average_nn_distance ( dist_matrix ) : ( row_idx , col_idx , val ) = scipy . sparse . find ( dist_matrix ) # Count/sum is done per row count_non_zero_elems = np . bincount ( row_idx ) sum_non_zero_elems = np . bincount ( row_idx , weights = val ) averages = sum_non_zero_elems / count_non_zero_elems if any ( np . isnan ( averages ) ) : warn ( "Embedding contains disconnected vertices which will be ignored." "Use umap.utils.disconnected_vertices() to identify them." ) return averages