All Projects → solzimer → skmeans

solzimer / skmeans

Licence: other
Super fast simple k-means implementation for unidimiensional and multidimensional data.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to skmeans

text-cluster
🍡 文本聚类 k-means算法及实战
Stars: ✭ 40 (-32.2%)
Mutual labels:  k-means, kmeans-clustering, kmeans-algorithm, k-means-clustering
ClusterAnalysis.jl
Cluster Algorithms from Scratch with Julia Lang. (K-Means and DBSCAN)
Stars: ✭ 22 (-62.71%)
Mutual labels:  cluster, k-means, k-means-clustering
Genetic-Algorithm-on-K-Means-Clustering
Implementing Genetic Algorithm on K-Means and compare with K-Means++
Stars: ✭ 37 (-37.29%)
Mutual labels:  cluster, k-means, kmeans-clustering
kmeans-clustering-cpp
A C++ implementation of simple k-means clustering algorithm.
Stars: ✭ 39 (-33.9%)
Mutual labels:  kmeans, kmeans-clustering, kmeans-algorithm
Clustering-in-Python
Clustering methods in Machine Learning includes both theory and python code of each algorithm. Algorithms include K Mean, K Mode, Hierarchical, DB Scan and Gaussian Mixture Model GMM. Interview questions on clustering are also added in the end.
Stars: ✭ 27 (-54.24%)
Mutual labels:  kmeans-clustering, kmeans-algorithm
MoTIS
Mobile(iOS) Text-to-Image search powered by multimodal semantic representation models(e.g., OpenAI's CLIP). Accepted at NAACL 2022.
Stars: ✭ 60 (+1.69%)
Mutual labels:  k-means, k-means-clustering
KMeans elbow
Code for determining optimal number of clusters for K-means algorithm using the 'elbow criterion'
Stars: ✭ 35 (-40.68%)
Mutual labels:  kmeans, kmeans-clustering
SparsifiedKMeans
KMeans for big data using preconditioning and sparsification, Matlab implementation. Aka k-means
Stars: ✭ 50 (-15.25%)
Mutual labels:  kmeans, k-means
MachineLearningSeries
Vídeos e códigos do Universo Discreto ensinando o fundamental de Machine Learning em Python. Para mais detalhes, acompanhar a playlist listada.
Stars: ✭ 20 (-66.1%)
Mutual labels:  k-means, k-means-clustering
tsp-essay
A fun study of some heuristics for the Travelling Salesman Problem.
Stars: ✭ 15 (-74.58%)
Mutual labels:  kmeans-clustering, kmeans-algorithm
Clustering Algorithms from Scratch
Implementing Clustering Algorithms from scratch in MATLAB and Python
Stars: ✭ 170 (+188.14%)
Mutual labels:  cluster
netpoll
Package netpoll implements a network poller based on epoll/kqueue.
Stars: ✭ 38 (-35.59%)
Mutual labels:  fast
kube-watch
Simple tool to get webhooks on Kubernetes cluster events
Stars: ✭ 21 (-64.41%)
Mutual labels:  cluster
laniakea
Laniakea is a utility for managing instances at various cloud providers and aids in setting up a fuzzing cluster.
Stars: ✭ 28 (-52.54%)
Mutual labels:  cluster
smk
SMK - Simple multimedia kit - C++ WebAssembly
Stars: ✭ 89 (+50.85%)
Mutual labels:  fast
Temps
λ A selfhostable serverless function runtime. Inspired by zeit now.
Stars: ✭ 15 (-74.58%)
Mutual labels:  cluster
ansible-role-pacemaker
Ansible role to deploy Pacemaker HA clusters
Stars: ✭ 19 (-67.8%)
Mutual labels:  cluster
Simplify.Web
Moved to https://github.com/SimplifyNet. Simplify.Web is a lightweight and fast server-side .NET web-framework based on MVC and OWIN for building HTTP based web-applications, RESTful APIs etc.
Stars: ✭ 23 (-61.02%)
Mutual labels:  fast
fast
fast.com cli speedtest
Stars: ✭ 46 (-22.03%)
Mutual labels:  fast
NodeMCU-BlackBox
ESP8266 based CAN-Bus Diagnostic Tool
Stars: ✭ 28 (-52.54%)
Mutual labels:  cluster

skmeans

Super fast simple k-means and k-means++ implementation for unidimiensional and multidimensional data. Works on nodejs and browser.

Installation

npm install skmeans

Usage

NodeJS

const skmeans = require("skmeans");

var data = [1,12,13,4,25,21,22,3,14,5,11,2,23,24,15];
var res = skmeans(data,3);

Browser

<!doctype html>
<html>
<head>
	<script src="skmeans.js"></script>
</head>
<body>
	<script>
		var data = [1,12,13,4,25,21,22,3,14,5,11,2,23,24,15];
		var res = skmeans(data,3);

		console.log(res);
	</script>
</body>
</html>

Results

{
	it: 2,
	k: 3,
	idxs: [ 2, 0, 0, 2, 1, 1, 1, 2, 0, 2, 0, 2, 1, 1, 0 ],
	centroids: [ 13, 23, 3 ]
}

API

skmeans(data,k,[centroids],[iterations])

Calculates unidimiensional and multidimensional k-means clustering on data. Parameters are:

  • data Unidimiensional or multidimensional array of values to be clustered. for unidimiensional data, takes the form of a simple array [1,2,3.....,n]. For multidimensional data, takes a NxM array [[1,2],[2,3]....[n,m]]
  • k Number of clusters
  • centroids Optional. Initial centroid values. If not provided, the algorith will try to choose an apropiate ones. Alternative values can be:
    • "kmrand" Cluster initialization will be random, but with extra checking, so there will no be two equal initial centroids.
    • "kmpp" The algorythm will use the k-means++ cluster initialization method.
  • iterations Optional. Maximum number of iterations. If not provided, it will be set to 10000.
  • distance function Optional. Custom distance function. Takes two points as arguments and returns a scalar number.

The function will return an object with the following data:

  • it The number of iterations performed until the algorithm has converged
  • k The cluster size
  • centroids The value for each centroid of the cluster
  • idxs The index to the centroid corresponding to each value of the data array
  • test Function to test new point membership

Examples

// k-means with 3 clusters. Random initialization
var res = skmeans(data,3);

// k-means with 3 clusters. Initial centroids provided
var res = skmeans(data,3,[1,5,9]);

// k-means with 3 clusters. k-means++ cluster initialization
var res = skmeans(data,3,"kmpp");

// k-means with 3 clusters. Random initialization. 10 max iterations
var res = skmeans(data,3,null,10);

// k-means with 3 clusters. Custom distance function
var res = skmeans(data,3,null,null,(x1,x2)=>Math.abs(x1-x2));

// Test new point
var res = skmeans(data,3,null,10);
res.test(6);

// Test new point with custom distance
var res = skmeans(data,3,null,10);
res.test(6,(x1,x2)=>Math.abs(x1-x2));
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].