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

Function knn

examples/machine_learning/bagging.cpp:50–60  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 1

baggingFunction · 0.70

Calls 2

distanceFunction · 0.70
minFunction · 0.50

Tested by

no test coverage detected