Changeset 11609:8f3dd402b200 in orange
 Timestamp:
 07/01/13 16:27:01 (10 months ago)
 Branch:
 default
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

source/orange/libsvm_interface.cpp
r11608 r11609 635 635 svm_node* x_space; 636 636 637 PDomain domain = examples>domain; 638 639 int classVarType; 640 if (domain>classVar) 641 classVarType = domain>classVar>varType; 642 else { 643 classVarType = TValue::NONE; 644 if(svm_type != ONE_CLASS) 645 raiseError("Domain has no class variable"); 646 } 647 if (classVarType == TValue::FLOATVAR && !(svm_type == EPSILON_SVR  svm_type == NU_SVR svm_type == ONE_CLASS)) 648 raiseError("Domain has continuous class"); 649 650 if (kernel_type == PRECOMPUTED && !kernelFunc) 651 raiseError("Custom kernel function not supplied"); 652 653 PExampleTable train_data = mlnew TExampleTable(examples, /* owns= */ false); 654 655 if (classVarType == TValue::INTVAR && svm_type != ONE_CLASS) { 656 /* Sort the train data by the class columns so the order of 657 * classVar.values is preserved in libsvm's model. 658 */ 659 vector<int> sort_columns(domain>variables>size()  1); 660 train_data>sort(sort_columns); 661 } 662 663 // Initialize svm parameters 637 664 param.svm_type = svm_type; 638 665 param.kernel_type = kernel_type; … … 644 671 param.eps = eps; 645 672 param.p = p; 646 param.cache_size =cache_size;647 param.shrinking =shrinking;648 param.probability =probability;673 param.cache_size = cache_size; 674 param.shrinking = shrinking; 675 param.probability = probability; 649 676 param.nr_weight = nr_weight; 650 677 … … 662 689 } 663 690 664 PDomain domain = examples>domain;665 666 int classVarType;667 if (domain>classVar)668 classVarType = domain>classVar>varType;669 else{670 classVarType = TValue::NONE;671 if(svm_type != ONE_CLASS)672 raiseError("Domain has no class variable");673 }674 if (classVarType == TValue::FLOATVAR && !(svm_type == EPSILON_SVR  svm_type == NU_SVR svm_type == ONE_CLASS))675 raiseError("Domain has continuous class");676 677 if (kernel_type == PRECOMPUTED && !kernelFunc)678 raiseError("Custom kernel function not supplied");679 680 PExampleTable train_data = mlnew TExampleTable(examples, /* owns= */ false);681 682 if (classVarType == TValue::INTVAR && svm_type != ONE_CLASS) {683 /* Sort the train data by the class columns so the order of684 * classVar.values is preserved in libsvm's model.685 */686 vector<int> sort_columns(domain>variables>size()  1);687 train_data>sort(sort_columns);688 }689 690 691 int numElements = getNumOfElements(train_data); 692 693 prob.x = NULL; 694 prob.y = NULL; 691 695 692 696 if (kernel_type != PRECOMPUTED) … … 698 702 param.gamma=1.0f/(float(numElements)/float(prob.l)1); 699 703 700 const char* error=svm_check_parameter(&prob, ¶m);704 const char* error=svm_check_parameter(&prob, ¶m); 701 705 if (error){ 702 706 free(x_space); 703 707 free(prob.y); 704 708 free(prob.x); 709 svm_destroy_param(¶m); 705 710 raiseError("LibSVM parameter error: %s", error); 706 711 } … … 722 727 if ((svm_type==C_SVC  svm_type==NU_SVC) && !model>nSV) { 723 728 svm_free_and_destroy_model(&model); 724 if (x_space) { 725 free(x_space); 726 } 729 free(x_space); 730 free(prob.x); 731 free(prob.y); 732 svm_destroy_param(¶m); 727 733 raiseError("LibSVM returned no support vectors"); 728 734 }
Note: See TracChangeset
for help on using the changeset viewer.