klotz: vornoi*

0 bookmark(s) - Sort by: Date ↓ / Title / - Bookmarks from other users for this tag

  1. from scipy.spatial import Voronoi, voronoi_plot_2d
    import pandas as pd
    import matplotlib.pyplot as plt
    from sklearn.cluster import KMeans

    location1="XXX"
    df = pd.read_csv(location1, encoding = "ISO-8859-1")

    #Run kmeans clustering
    X = df ['long','lat' » ].values #~2k locations in the UK
    y=df 'label' » .values #Label is a 0 or 1
    kmeans = KMeans(n_clusters=30, random_state=0).fit(X, y)
    centers=kmeans.cluster_centers_

    plt.scatter(centers :,0 » ,centers :,1 » , marker='s', s=100)


    vor = Voronoi(centers)
    fig = voronoi_plot_2d(vor,plt.gca())

    plt.show()
    2021-09-24 Tags: , , by klotz

Top of the page

First / Previous / Next / Last / Page 1 of 0 SemanticScuttle - klotz.me: Tags: vornoi

About - Propulsed by SemanticScuttle