def retrieve_neighborhood_simple(allpts, cluster_idxs, nnfinder, pt_idx=None):
    """
    DEPRECATED
    Retrieve candidates to expand a given cluster. The radius is set to the largest 1-NN distance within all cluster
    points. This method omits the lower bound check and follows directly the definition for the radius.
    :param allpts: NxM 2d-array with N points of M dimensions. These are all points in the dataset.
    :param cluster_idxs: the indices whthin allpts of the (partial) cluster to be evaluated/expanded.
    :param nnfinder: instance of scipy's NearestNeighbor fit with all points in the dataset.
    :param pt_idx: index within allpts of the reference point to be checked for neighboring candidates to expand
    the cluster. If None, the first index of cluster_idxs is going to be used instead.
    :return: list of point indices that are within a radius r from the query point, including the query point.
    """
    cluster = allpts[cluster_idxs]
    two_nnfinder = NearestNeighbors(2, algorithm='ball_tree', p=2).fit(cluster)
    r = two_nnfinder.kneighborgs(cluster)[0][:, 1].max()  # Max NN distance of pts
    if pt_idx is None:
        pt_idx = cluster_idxs[0]
    query_nn_dists, query_nn_idxs = nnfinder.kneighbors([allpts[pt_idx]])
    return query_nn_idxs[query_nn_dists <= r]  # Discard the input point itself
Example #2
0
def retrieve_neighborhood_simple(allpts, cluster_idxs, nnfinder, pt_idx=None):
    """
    DEPRECATED
    Retrieve candidates to expand a given cluster. The radius is set to the largest 1-NN distance within all cluster
    points. This method omits the lower bound check and follows directly the definition for the radius.
    :param allpts: NxM 2d-array with N points of M dimensions. These are all points in the dataset.
    :param cluster_idxs: the indices whthin allpts of the (partial) cluster to be evaluated/expanded.
    :param nnfinder: instance of scipy's NearestNeighbor fit with all points in the dataset.
    :param pt_idx: index within allpts of the reference point to be checked for neighboring candidates to expand
    the cluster. If None, the first index of cluster_idxs is going to be used instead.
    :return: list of point indices that are within a radius r from the query point, including the query point.
    """
    cluster = allpts[cluster_idxs]
    two_nnfinder = NearestNeighbors(2, algorithm='ball_tree', p=2).fit(cluster)
    r = two_nnfinder.kneighborgs(cluster)[0][:, 1].max()  # Max NN distance of pts
    if pt_idx is None:
        pt_idx = cluster_idxs[0]
    query_nn_dists, query_nn_idxs = nnfinder.kneighbors([allpts[pt_idx]])
    return query_nn_idxs[query_nn_dists <= r]  # Discard the input point itself