All Projects → dstein64 → kmeans1d

dstein64 / kmeans1d

Licence: MIT license
⭐ A Python package for optimal 1D k-means clustering.

Programming Languages

C++
36643 projects - #6 most used programming language
python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to kmeans1d

Colorz
🎨 A k-means color scheme generator.
Stars: ✭ 134 (+282.86%)
Mutual labels:  kmeans
faiss-ruby
Efficient similarity search and clustering for Ruby
Stars: ✭ 62 (+77.14%)
Mutual labels:  kmeans
video-scene-detection
Video Scene Detection Based on the Optimal Sequential Grouping algorithm
Stars: ✭ 62 (+77.14%)
Mutual labels:  dynamic-programming
Mlkit
A simple machine learning framework written in Swift 🤖
Stars: ✭ 144 (+311.43%)
Mutual labels:  kmeans
Machine learning
Estudo e implementação dos principais algoritmos de Machine Learning em Jupyter Notebooks.
Stars: ✭ 161 (+360%)
Mutual labels:  kmeans
StructDualDynProg.jl
Implementation of SDDP (Stochastic Dual Dynamic Programming) using the StructJuMP modeling interface
Stars: ✭ 22 (-37.14%)
Mutual labels:  dynamic-programming
Vizuka
Explore high-dimensional datasets and how your algo handles specific regions.
Stars: ✭ 100 (+185.71%)
Mutual labels:  kmeans
dynamic-programming-visualization
In browser visualization for dynamic programming algorithms
Stars: ✭ 14 (-60%)
Mutual labels:  dynamic-programming
Cukatify
Cukatify is a music social media project
Stars: ✭ 21 (-40%)
Mutual labels:  kmeans
text clustering
文本聚类(Kmeans、DBSCAN、LDA、Single-pass)
Stars: ✭ 230 (+557.14%)
Mutual labels:  kmeans
Kmeans Gmm Hmm
HMM based on KMeans and GMM
Stars: ✭ 146 (+317.14%)
Mutual labels:  kmeans
Machine Learning Models
Decision Trees, Random Forest, Dynamic Time Warping, Naive Bayes, KNN, Linear Regression, Logistic Regression, Mixture Of Gaussian, Neural Network, PCA, SVD, Gaussian Naive Bayes, Fitting Data to Gaussian, K-Means
Stars: ✭ 160 (+357.14%)
Mutual labels:  kmeans
InterviewPrep
A repository containing link of good interview questions
Stars: ✭ 54 (+54.29%)
Mutual labels:  dynamic-programming
Awesome Quantum Machine Learning
Here you can get all the Quantum Machine learning Basics, Algorithms ,Study Materials ,Projects and the descriptions of the projects around the web
Stars: ✭ 1,940 (+5442.86%)
Mutual labels:  kmeans
deepvis
machine learning algorithms in Swift
Stars: ✭ 54 (+54.29%)
Mutual labels:  kmeans
Kdtree
Absolute balanced kdtree for fast kNN search.
Stars: ✭ 131 (+274.29%)
Mutual labels:  kmeans
algoexpert
AlgoExpert is an online platform that helps software engineers to prepare for coding and technical interviews.
Stars: ✭ 8 (-77.14%)
Mutual labels:  dynamic-programming
DSA--GeeksForGeeks
DSA course solutions in C++ Jump to below directly for more problems
Stars: ✭ 47 (+34.29%)
Mutual labels:  dynamic-programming
MCScanX
MCScanX: Multiple Collinearity Scan toolkit X version. The most popular synteny analysis tool in the world!
Stars: ✭ 144 (+311.43%)
Mutual labels:  dynamic-programming
recursion-and-dynamic-programming
Julia and Python recursion algorithm, fractal geometry and dynamic programming applications including Edit Distance, Knapsack (Multiple Choice), Stock Trading, Pythagorean Tree, Koch Snowflake, Jerusalem Cross, Sierpiński Carpet, Hilbert Curve, Pascal Triangle, Prime Factorization, Palindrome, Egg Drop, Coin Change, Hanoi Tower, Cantor Set, Fibo…
Stars: ✭ 37 (+5.71%)
Mutual labels:  dynamic-programming

Build Status

kmeans1d

A Python library with an implementation of k-means clustering on 1D data, based on the algorithm from Xiaolin (1991), as presented by Gronlund et al. (2017, Section 2.2).

Globally optimal k-means clustering is NP-hard for multi-dimensional data. Lloyd's algorithm is a popular approach for finding a locally optimal solution. For 1-dimensional data, there are polynomial time algorithms. The algorithm implemented here is an O(kn + n log n) dynamic programming algorithm for finding the globally optimal k clusters for n 1D data points.

The code is written in C++, and wrapped with Python.

Requirements

kmeans1d supports Python 3.x.

Installation

kmeans1d is available on PyPI, the Python Package Index.

$ pip3 install kmeans1d

Example Usage

import kmeans1d

x = [4.0, 4.1, 4.2, -50, 200.2, 200.4, 200.9, 80, 100, 102]
k = 4

clusters, centroids = kmeans1d.cluster(x, k)

print(clusters)   # [1, 1, 1, 0, 3, 3, 3, 2, 2, 2]
print(centroids)  # [-50.0, 4.1, 94.0, 200.5]

Tests

Tests are in tests/.

# Run tests
$ python3 -m unittest discover tests -v

Development

The underlying C++ code can be built in-place, outside the context of pip. This requires Python development tools for building Python modules (e.g., the python3-dev package on Ubuntu). gcc, clang, and MSVC have been tested.

$ python3 setup.py build_ext --inplace

The packages GitHub action can be manually triggered (Actions > packages > Run workflow) to build wheels and a source distribution.

License

The code in this repository has an MIT License.

See LICENSE.

References

[1] Wu, Xiaolin. "Optimal Quantization by Matrix Searching." Journal of Algorithms 12, no. 4 (December 1, 1991): 663

[2] Gronlund, Allan, Kasper Green Larsen, Alexander Mathiasen, Jesper Sindahl Nielsen, Stefan Schneider, and Mingzhou Song. "Fast Exact K-Means, k-Medians and Bregman Divergence Clustering in 1D." ArXiv:1701.07204 [Cs], January 25, 2017. http://arxiv.org/abs/1701.07204.

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].