songjhaha / julia-kmeans1d

Python package for 1d kmeans clustering, implemented with julia and jnumpy.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

julia-kmeans1d

A Python library with an implementation of k-means clustering on 1D data.

The core algorithm is wrote on julia by pabloferz and Raf in discourse, which is a translation of C++ code.

Here we use jnumpy for exporting julia function to python function.

Benchmark

from jl_kmeans1d import jl_cluster
from kmeans1d import cluster
import numpy as np

X1 = np.random.rand(1000)
%timeit jl_cluster(X1, 32) # 2.18 ms
%timeit cluster(X1, 32) # 6.15 ms

X2 = np.random.rand(1000000)
%timeit jl_cluster(X2, 32) # 4.68s
%timeit cluster(X2, 32) # 9.38s

About

Python package for 1d kmeans clustering, implemented with julia and jnumpy.


Languages

Language:Julia 94.4%Language:Python 5.6%