Changeset 9347:d25d6efeab13 in orange


Ignore:
Timestamp:
12/13/11 15:23:31 (2 years ago)
Author:
ales_erjavec <ales.erjavec@…>
Branch:
default
Convert:
d57778a197b2b6473610ab70986ac2eb2aface9f
Message:

If a probability model was requested LibSVM uses 5 fold
cross-validation to estimate the prediction errors. This includes a
random shuffle of the data. To make the results reproducible and
consistent we reset the random seed (srand). This could have an affect
on other algorithms using the stdlib's rand/srand functions.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • source/orange/libsvm_interface.cpp

    r9187 r9347  
    569569    } 
    570570 
    571 //  param.learner=this; 
    572 //  param.classifier=NULL; 
    573     //cout<<param.kernel_type<<endl; 
    574  
    575 //  tempExamples=examples; 
    576     //int exlen=examples->domain->attributes->size(); 
    577571    int classVarType; 
    578572    if(examples->domain->classVar) 
     
    596590        x_space = init_precomputed_problem(prob, examples, kernelFunc.getReference()); 
    597591 
    598 //  prob.l=examples->numberOfExamples(); 
    599 //  prob.y=Malloc(double,prob.l); 
    600 //  prob.x=Malloc(svm_node*, prob.l); 
    601 //  x_space=Malloc(svm_node, numElements); 
    602 //  int k=0; 
    603 //  svm_node *node=x_space; 
    604 //  PEITERATE(iter, examples){ 
    605 //      prob.x[k]=node; 
    606 //      node=example_to_svm(*iter, node, k, (param.kernel_type==CUSTOM)? 1:0); 
    607 //      switch(classVarType){ 
    608 //          case TValue::FLOATVAR:{ 
    609 //              prob.y[k]=(*iter).getClass().floatV; 
    610 //              break; 
    611 //          } 
    612 //          case TValue::INTVAR:{ 
    613 //              prob.y[k]=(*iter).getClass().intV; 
    614 //              break; 
    615 //          } 
    616 //      } 
    617 //      k++; 
    618 //  } 
    619  
    620592    if(param.gamma==0) 
    621593        param.gamma=1.0f/(float(numElements)/float(prob.l)-1); 
     
    628600        raiseError("LibSVM parameter error: %s", error); 
    629601    } 
    630     //cout<<"training"<<endl; 
     602 
    631603//  svm_print_string = (verbose)? &print_string_stdout : &print_string_null; 
     604 
     605    // If a probability model was requested LibSVM uses 5 fold 
     606    // cross-validation to estimate the prediction errors. This includes a 
     607    // random shuffle of the data. To make the results reproducible and 
     608    // consistent with 'svm-train' (which always learns just on one dataset 
     609    // in a process run) we reset the random seed. This could have unintended 
     610    // consequences. 
     611    if (param.probability) 
     612    { 
     613        srand(1); 
     614    } 
    632615    svm_set_print_string_function((verbose)? NULL : &print_string_null); 
    633616    model=svm_train(&prob,&param); 
Note: See TracChangeset for help on using the changeset viewer.