| 362 | } |
| 363 | |
| 364 | int testEmptyKNNValidationGood() { |
| 365 | |
| 366 | Specification::Model m1; |
| 367 | |
| 368 | KNNValidatorTests::generateInterface(m1); |
| 369 | |
| 370 | auto *knnClassifier = m1.mutable_knearestneighborsclassifier(); |
| 371 | KNNValidatorTests::setNumberOfNeighbors(knnClassifier, 3, true); |
| 372 | knnClassifier->mutable_uniformweighting(); |
| 373 | |
| 374 | auto *nnIndex = knnClassifier->mutable_nearestneighborsindex(); |
| 375 | nnIndex->mutable_squaredeuclideandistance(); |
| 376 | auto *kdTree = nnIndex->mutable_singlekdtreeindex(); |
| 377 | kdTree->set_leafsize(30); |
| 378 | |
| 379 | // Validation should fail since we are not telling the label type. |
| 380 | Result res = validate<MLModelType_kNearestNeighborsClassifier>(m1); |
| 381 | ML_ASSERT_BAD(res); |
| 382 | |
| 383 | knnClassifier->set_defaultstringlabel("Default"); |
| 384 | |
| 385 | // Validation should pass now. |
| 386 | res = validate<MLModelType_kNearestNeighborsClassifier>(m1); |
| 387 | ML_ASSERT_GOOD(res); |
| 388 | |
| 389 | knnClassifier->clear_defaultstringlabel(); |
| 390 | |
| 391 | // Validation should fail since we are not telling the label type. |
| 392 | res = validate<MLModelType_kNearestNeighborsClassifier>(m1); |
| 393 | ML_ASSERT_BAD(res); |
| 394 | |
| 395 | return 0; |
| 396 | } |
| 397 | |
| 398 | int testLabelTypeMismatchTest() { |
| 399 |
nothing calls this directly
no test coverage detected