MCPcopy Create free account
hub / github.com/apple/coremltools / testKNNValidatorGood

Function testKNNValidatorGood

mlmodel/tests/KNNValidatorTests.cpp:339–362  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

337}
338
339int testKNNValidatorGood() {
340
341 Specification::Model m1;
342
343 KNNValidatorTests::generateInterface(m1);
344
345 auto *knnClassifier = m1.mutable_knearestneighborsclassifier();
346 KNNValidatorTests::setNumberOfNeighbors(knnClassifier, 3, true);
347 knnClassifier->mutable_uniformweighting();
348
349 auto *nnIndex = knnClassifier->mutable_nearestneighborsindex();
350 nnIndex->mutable_squaredeuclideandistance();
351 auto *kdTree = nnIndex->mutable_singlekdtreeindex();
352 kdTree->set_leafsize(30);
353
354 KNNValidatorTests::addDataPoints(knnClassifier);
355 KNNValidatorTests::addStringLabels(knnClassifier);
356
357 Result res = validate<MLModelType_kNearestNeighborsClassifier>(m1);
358 ML_ASSERT_GOOD(res);
359
360 return 0;
361
362}
363
364int testEmptyKNNValidationGood() {
365

Callers

nothing calls this directly

Calls 4

generateInterfaceFunction · 0.85
setNumberOfNeighborsFunction · 0.85
addDataPointsFunction · 0.85
addStringLabelsFunction · 0.85

Tested by

no test coverage detected