Skip to main content

emit_spatial_kmeans_test

Function emit_spatial_kmeans_test 

Source
pub fn emit_spatial_kmeans_test(
    spec: &KmeansSpec,
    points: &Fill,
    p: KmeansPar,
    class_name: &str,
) -> Result<String, String>
Expand description

Emit a Spatial REGRESSION-HARNESS k-means clustering with the structure of Spatial’s own Kmeans app — the centroids loaded from the first K points, iters epochs each a MemReduce over ts-point tiles of a MemReduce over the tile’s points (each point’s distance to every centroid a Reduce over the features, the nearest found by a min and an index reduce, the point added to its centroid’s row as a one-hot tile), then every centroid set to its row over its count — at our shape and the app’s runtime arguments, over the program’s own data, written at the app’s X = Int (the app’s kmeans[T:Num] instantiated). The app keeps each centroid’s count as a last feature of every point fixed at 1 (D = f + 1 columns), where the program keeps counts; equally near centroids go to the last (the app’s max of the matching indices) or, for a program keeping the first, to the first (a min). The gold is the clustering the program computes, evaluated on the host the way the accelerator computes it, the nearest centroid chosen by distance and then by index whichever way the host folds. The app computes in Spatial’s 32-bit Int; a distance or a sum that would wrap there is refused, as is a tile that does not divide the points.