Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/gbroques/k-means
K-Means and Bisecting K-Means clustering algorithms implemented in Python 3.
https://github.com/gbroques/k-means
bisecting-kmeans centroid clustering euclidean-distance k-means k-means-clustering manhattan-distance python-3-6 python3
Last synced: about 1 month ago
JSON representation
K-Means and Bisecting K-Means clustering algorithms implemented in Python 3.
- Host: GitHub
- URL: https://github.com/gbroques/k-means
- Owner: gbroques
- License: mit
- Created: 2018-04-15T19:32:02.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2022-12-08T00:58:04.000Z (about 2 years ago)
- Last Synced: 2023-03-01T09:56:26.976Z (almost 2 years ago)
- Topics: bisecting-kmeans, centroid, clustering, euclidean-distance, k-means, k-means-clustering, manhattan-distance, python-3-6, python3
- Language: Jupyter Notebook
- Size: 134 KB
- Stars: 1
- Watchers: 2
- Forks: 1
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# K-Means Clustering
[![Build Status](https://travis-ci.org/gbroques/k-means.svg?branch=master)](https://travis-ci.org/gbroques/k-means)
[![Coverage Status](https://coveralls.io/repos/github/gbroques/k-means/badge.svg?branch=master)](https://coveralls.io/github/gbroques/k-means?branch=master)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
```python
from typing import Listfrom dataviz import generate_clusters
from dataviz import plot_clusters
from kmeans import KMeansdef 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](k-means-plot.png)
```python
print('Total Sum of Squared Error (SSE): {}'.format(k_means.inertia_))
```Total Sum of Squared Error (SSE): 230.0880894560679