MCPcopy Create free account
hub / github.com/arrayfire/arrayfire / clusterize

Function clusterize

examples/machine_learning/kmeans.cpp:32–42  ·  view source on GitHub ↗

Get cluster id of each location in data

Source from the content-addressed store, hash-verified

30
31// Get cluster id of each location in data
32array clusterize(const array data, const array means) {
33 // Get manhattan distance
34 array dists = distance(data, means);
35
36 // get the locations of minimum distance
37 array idx, val;
38 min(val, idx, dists, 1);
39
40 // Return cluster IDs
41 return idx;
42}
43
44array new_means(array data, array clusters, int k) {
45 int d = data.dims(2);

Callers 1

kmeansFunction · 0.85

Calls 2

distanceFunction · 0.70
minFunction · 0.50

Tested by

no test coverage detected