Giter Site home page Giter Site logo

kmeans-parallel's Introduction

#Scalable K-means Clustering

Dask is a flexible parallel computing library for analytic computing and provides parallelized NumPy array and Pandas DataFrame objects.

While the ordinary Lloyd's algorithm could fit into memory on most modern machines for small datasets, here we'll take a more scalable approach, utilizing Dask to do our data ingestion and manipulation out-of-core.

A good place to start with : https://jakevdp.github.io/blog/2015/08/14/out-of-core-dataframes-in-python/

Sample Instruction to begin with:


    import numpy as np
    from sklearn.datasets.samples_generator import make_blobs
    import dask.array as da
    from dask.dot import dot_graph
    from sklearn import metrics

    from kmeans import kmeans

    # Generate sample data
    centers = [[1, 1], [-1, -1], [1, -1]]

    X, labels_true = make_blobs(n_samples=30, centers=centers, cluster_std=0.5,
		                    random_state=0)

    result = kmeans(X, k=10)

    # Print Task-Scheduling graph
    dot_graph(result[0].dask, filename='clusters')
    dot_graph(result[1].dask, filename='centroids')
    
    print "Result:\nClusters"
    print result[0].compute()

    print "Centroids"
    print result[1].compute()

    print("Silhouette Coefficient: %0.3f"
      % metrics.silhouette_score(X.tolist(), result[0].compute().tolist(), metric='euclidean'))

    

kmeans-parallel's People

Contributors

jiteshjha avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.