MCPcopy Create free account
hub / github.com/PointCloudLibrary/pcl / classification

Method classification

ml/src/svm_wrapper.cpp:654–734  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

652}
653
654bool
655pcl::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

Callers

nothing calls this directly

Calls 11

svm_get_svm_typeFunction · 0.85
svm_get_nr_classFunction · 0.85
svm_get_svr_probabilityFunction · 0.85
svm_predict_probabilityFunction · 0.85
svm_predictFunction · 0.85
getClassNameFunction · 0.50
clearMethod · 0.45
resizeMethod · 0.45
push_backMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected