DBCV.py 文件源码

python
阅读 68 收藏 0 点赞 0 评论 0

项目:DBCV 作者: christopherjenness 项目源码 文件源码
def _core_dist(point, neighbors, dist_function):
    """
    Computes the core distance of a point.
    Core distance is the inverse density of an object.

    Args:
        point (np.array): array of dimensions (n_features,)
            point to compute core distance of
        neighbors (np.ndarray): array of dimensions (n_neighbors, n_features):
            array of all other points in object class
        dist_dunction (func): function to determine distance between objects
            func args must be [np.array, np.array] where each array is a point

    Returns: core_dist (float)
        inverse density of point
    """
    n_features = np.shape(point)[0]
    n_neighbors = np.shape(neighbors)[1]

    numerator = 0
    for row in neighbors:
        if not np.array_equal(point, row):
            numerator += (1/dist_function(point, row))**n_features
    core_dist = (numerator / (n_neighbors)) ** (-1/n_features)
    return core_dist
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号