Liking cljdoc? Tell your friends :D

hara.math.stats.kmeans


centroidclj

(centroid ps)

finds the central position of a group of points

(centroid [[3 3] [4 4] [5 5] [6 6]]) => [9/2 9/2]

finds the central position of  a group of points

(centroid [[3 3] [4 4] [5 5] [6 6]])
=> [9/2 9/2]
raw docstring

clusterclj

(cluster ps centroids)

takes an array centroids and groups points based upon closest distance

(cluster [[0 0] [1 1] [2 2] [3 3] [4 4] [5 5] [6 6]] [[1 1] [4 4]]) => [[[0 0] [1 1] [2 2]] [[3 3] [4 4] [5 5] [6 6]]]

takes an array centroids and groups points based upon closest distance

(cluster [[0 0] [1 1] [2 2] [3 3] [4 4] [5 5] [6 6]]
         [[1 1] [4 4]])
=> [[[0 0] [1 1] [2 2]]
    [[3 3] [4 4] [5 5] [6 6]]]
raw docstring

distance2clj

(distance2 p0 pc)

sum of squared distances between two points

(distance2 [1 3 5] [2 4 6]) => 3

sum of squared distances between two points

(distance2 [1 3 5] [2 4 6])
=> 3
raw docstring

initial-centroidsclj

(initial-centroids ps k)

finds a set of centroids from the initial set of points

finds a set of centroids from the initial set of points
raw docstring

k-meansclj

(k-means ps k)
(k-means ps k max-steps)

clusters points together based on the number of groups specified

(set (k-means [[0.2 0.4] [0.2 0.3] [0.3 0.4] [1.2 0.4] [1.1 0.3] [2.3 0.4]] 2)) => (any #{[[0.2 0.4] [0.2 0.3] [0.3 0.4]] [[1.2 0.4] [1.1 0.3] [2.3 0.4]]} #{[[0.2 0.4] [0.2 0.3] [0.3 0.4] [1.2 0.4] [1.1 0.3]] [[2.3 0.4]]})

clusters points together based on the number of groups specified

(set (k-means [[0.2 0.4] [0.2 0.3] [0.3 0.4]
               [1.2 0.4] [1.1 0.3] [2.3 0.4]]
              2))
=> (any #{[[0.2 0.4] [0.2 0.3] [0.3 0.4]]
          [[1.2 0.4] [1.1 0.3] [2.3 0.4]]}
        #{[[0.2 0.4] [0.2 0.3] [0.3 0.4] [1.2 0.4] [1.1 0.3]]
          [[2.3 0.4]]})
raw docstring

min-indexclj

(min-index p0 centroids)

finds the index of the centroid closest to p0

(min-index [0 0] [[-1 -1] [0.5 0.5] [1 1] ]) => 1

finds the index of the centroid closest to `p0`

(min-index [0 0] [[-1 -1] [0.5 0.5] [1 1] ])
=> 1
raw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close