Giter Site home page Giter Site logo

gbroques / k-means Goto Github PK

View Code? Open in Web Editor NEW
2.0 3.0 1.0 137 KB

K-Means and Bisecting K-Means clustering algorithms implemented in Python 3.

License: MIT License

Python 42.69% Jupyter Notebook 57.31%
k-means k-means-clustering clustering python3 python-3-6 bisecting-kmeans manhattan-distance euclidean-distance centroid

k-means's Introduction

K-Means Clustering

Build Status Coverage Status

A k-means clustering implementation in Python.

API inspired by Scikit-learn.

Reference: Introduction to Data Mining (1st Edition) by Pang-Ning Tan Section 8.2, Page 496

Usage

from typing import List

from dataviz import generate_clusters
from dataviz import plot_clusters
from kmeans import KMeans

def generate_data(num_clusters: int, seed=None) -> List[List]:
    num_points = 20
    spread = 7
    bounds = (1, 100)
    return generate_clusters(num_clusters, num_points, spread, bounds, bounds, seed)

num_clusters = 4
clusters = generate_data(num_clusters, seed=1)
k_means = KMeans(num_clusters=num_clusters, seed=4235)
k_means.fit(clusters)
plot_clusters(clusters, k_means.labels_, k_means.centroids_)

png

print('Total Sum of Squared Error (SSE): {}'.format(k_means.inertia_))
Total Sum of Squared Error (SSE): 230.0880894560679

k-means's People

Contributors

gbroques avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

mustafaali96

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.