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

Function knn

examples/machine_learning/knn.cpp:51–61  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

49}
50
51array knn(array &train_feats, array &test_feats, array &train_labels) {
52 // Find distances between training and testing sets
53 array dist = distance(train_feats, test_feats);
54
55 // Find the neighbor producing the minimum distance
56 array val, idx;
57 min(val, idx, dist);
58
59 // Return the labels
60 return train_labels(idx);
61}
62
63void knn_demo(bool console, int perc) {
64 array train_images, train_labels;

Callers 1

knn_demoFunction · 0.70

Calls 2

distanceFunction · 0.70
minFunction · 0.50

Tested by

no test coverage detected