| 47 | } |
| 48 | |
| 49 | void addDataPoints(Specification::KNearestNeighborsClassifier* nnModel) { |
| 50 | |
| 51 | std::vector<float> point0 = {0, 0, 0, 0}; |
| 52 | std::vector<float> point0b = {0, 0.1f, 0, 0}; |
| 53 | |
| 54 | std::vector<float> point1 = {1, 0, 0, 0}; |
| 55 | std::vector<float> point1b = {1, 0, 0.1f, 0}; |
| 56 | |
| 57 | std::vector<float> point2 = {2.1f, 0, 0, 0}; |
| 58 | std::vector<float> point2b = {2.1f, 0, 0, 0.1f}; |
| 59 | |
| 60 | std::vector<std::vector<float>> points = {point0, point1, point2, point0b, point1b, point2b}; |
| 61 | size_t pointCount = 6; |
| 62 | |
| 63 | auto *nnIndex = nnModel->mutable_nearestneighborsindex(); |
| 64 | nnIndex->set_numberofdimensions(4); |
| 65 | |
| 66 | for (size_t i = 0; i < pointCount; i++) { |
| 67 | nnIndex->add_floatsamples(); |
| 68 | const auto& sample = points[i]; |
| 69 | for (size_t j = 0; j < 4; j++) { |
| 70 | nnIndex->mutable_floatsamples((int)i)->add_vector(sample[j]); |
| 71 | } |
| 72 | } |
| 73 | |
| 74 | } |
| 75 | |
| 76 | |
| 77 | void addIntLabels(Specification::KNearestNeighborsClassifier* nnModel) { |
no outgoing calls
no test coverage detected