gda_sdm_functions.py
def plot_nb_dists(X, nearest_neighbor, metric='euclidean', ylim=None):
    """ Plots distance sorted by `neared_neighbor`th

    Args:
        X (list of lists): list with data tuples
        nearest_neighbor (int): nr of nearest neighbor to plot
        metric (string): name of scipy metric function to use
    """
    
    tree = KDTree(X, leaf_size=2) 


    if not isinstance(nearest_neighbor, list):
        nearest_neighbor = [nearest_neighbor]

    max_nn = max(nearest_neighbor)

    dist, _ = tree.query(X, k=max_nn + 1)

    plt.figure()

    for nnb in nearest_neighbor:
        col = dist[:, nnb]
        col.sort()
        plt.plot(col, label="{}th nearest neighbor".format(nnb))
 
    #plt.ylim(0, min(250, max(dist[:, max_nn])))
    plt.ylabel("Distance to k nearest neighbor")
    plt.xlabel("Points sorted according to distance of k nearest neighbor")
    plt.ylim(0,ylim)
    plt.grid()
    plt.legend()
    plt.show()
 Plots distance sorted by `neared_neighbor`th

    Args:
        X (list of lists): list with data tuples
        nearest_neighbor (int): nr of nearest neighbor to plot
        metric (string): name of scipy metric function to use
    
Plots distance sorted by `neared_neighbor`th
Plots distance sorted by ` neared_neighbor ` th
def plot_nb_dists(X, nearest_neighbor, metric='euclidean', ylim=None):
    tree = KDTree(X, leaf_size=2) 
    if not isinstance(nearest_neighbor, list):
        nearest_neighbor = [nearest_neighbor]
    max_nn = max(nearest_neighbor)
    dist, _ = tree.query(X, k=max_nn + 1)
    plt.figure()
    for nnb in nearest_neighbor:
        col = dist[:, nnb]
        col.sort()
        plt.plot(col, label="{}th nearest neighbor".format(nnb))
    plt.ylabel("Distance to k nearest neighbor")
    plt.xlabel("Points sorted according to distance of k nearest neighbor")
    plt.ylim(0,ylim)
    plt.grid()
    plt.legend()
    plt.show()
def plot_nb_dists ( X , nearest_neighbor , metric = 'euclidean' , ylim = None ) : tree = KDTree ( X , leaf_size = 2 ) if not isinstance ( nearest_neighbor , list ) : nearest_neighbor = [ nearest_neighbor ] max_nn = max ( nearest_neighbor ) dist , _ = tree . query ( X , k = max_nn + 1 ) plt . figure ( ) for nnb in nearest_neighbor : col = dist [ : , nnb ] col . sort ( ) plt . plot ( col , label = "{}th nearest neighbor" . format ( nnb ) ) plt . ylabel ( "Distance to k nearest neighbor" ) plt . xlabel ( "Points sorted according to distance of k nearest neighbor" ) plt . ylim ( 0 , ylim ) plt . grid ( ) plt . legend ( ) plt . show ( )
Plots distance sorted by `neared_neighbor`th
Plots distance sorted by ` neared_neighbor ` th
""" Plots distance sorted by `neared_neighbor`th

    Args:
        X (list of lists): list with data tuples
        nearest_neighbor (int): nr of nearest neighbor to plot
        metric (string): name of scipy metric function to use
    """ #plt.ylim(0, min(250, max(dist[:, max_nn])))

X
list with data tuples
list with data tuples
nearest_neighbor
nr of nearest neighbor to plot
nr of nearest neighbor to plot
metric
name of scipy metric function to use
name of scipy metric function to use
ylim