Created
July 4, 2019 23:33
-
-
Save dstein64/0e0d7f80ce6148881926b8fd6852072a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment