| 652 | } |
| 653 | |
| 654 | bool |
| 655 | pcl::SVMClassify::classification() |
| 656 | { |
| 657 | if (model_.l == 0) { |
| 658 | PCL_ERROR("[pcl::%s::classification] Classifier model has no data.\n", |
| 659 | getClassName().c_str()); |
| 660 | return false; |
| 661 | } |
| 662 | |
| 663 | if (prob_.l == 0) { |
| 664 | PCL_ERROR("[pcl::%s::classification] Input dataset has no data.\n", |
| 665 | getClassName().c_str()); |
| 666 | return false; |
| 667 | } |
| 668 | |
| 669 | if (predict_probability_) { |
| 670 | if (svm_check_probability_model(&model_) == 0) { |
| 671 | PCL_WARN( |
| 672 | "[pcl::%s::classification] Classifier model does not support probability " |
| 673 | "estimates. Automatically disabled.\n", |
| 674 | getClassName().c_str()); |
| 675 | predict_probability_ = false; |
| 676 | } |
| 677 | } |
| 678 | else { |
| 679 | if (svm_check_probability_model(&model_) != 0) |
| 680 | PCL_WARN("[pcl::%s::classification] Classifier model supports probability " |
| 681 | "estimates, but disabled in prediction.\n", |
| 682 | getClassName().c_str()); |
| 683 | } |
| 684 | |
| 685 | int svm_type = svm_get_svm_type(&model_); |
| 686 | int nr_class = svm_get_nr_class(&model_); |
| 687 | |
| 688 | double* prob_estimates = nullptr; |
| 689 | |
| 690 | prediction_.clear(); |
| 691 | |
| 692 | if (predict_probability_) { |
| 693 | if (svm_type == NU_SVR || svm_type == EPSILON_SVR) |
| 694 | PCL_WARN("[pcl::%s::classificationTest] Prob. model for test data: target value " |
| 695 | "= predicted value + z,\nz: Laplace distribution " |
| 696 | "e^(-|z|/sigma)/(2sigma),sigma=%g\n", |
| 697 | getClassName().c_str(), |
| 698 | svm_get_svr_probability(&model_)); |
| 699 | else { |
| 700 | prob_estimates = static_cast<double*>(malloc(nr_class * sizeof(double))); |
| 701 | } |
| 702 | } |
| 703 | |
| 704 | int ii = 0; |
| 705 | |
| 706 | prediction_.resize(prob_.l); |
| 707 | |
| 708 | while (ii < prob_.l) { |
| 709 | double predict_label; |
| 710 | // char *idx, *val, *endptr; |
| 711 | // int inst_max_index = -1; // strtol gives 0 if wrong format, and precomputed |
nothing calls this directly
no test coverage detected