This version is for training, for prediction mKernelQuids doesn't have to be used. The resulting svm_problem is used by LinkSvm.cpp to access the distributed kernel matrix. In order to be consitent with how libsvm handles kernel matrices we create a problem in which the first column contains indices in the kernel matrix. libsvm want these to be 1-based in stead of 0-based. That explains the +1 after GetIndex(q). We hacked libsvm to substract 1 from this index everytime it is used. Definition at line 107 of file TrainDataSrcKernelDistributed.h. References Impala::Core::Table::TableTem< Col1T, Col2T, Col3T, Col4T, Col5T, Col6T, Col7T, Col8T, Col9T >::Get1(), Impala::Core::Table::QuidTable::GetIndex(), svm_node::index, Impala::Core::Table::AnnotationTable::IsNegative(), Impala::Core::Table::AnnotationTable::IsPositive(), svm_problem::l, Impala::Core::Training::TrainDataSrc::mAnnotation, mKernelQuids, Impala::Core::Table::Table::Size(), svm_node::value, svm_problem::x, and svm_problem::y. Referenced by MakeSvmProblem(). 00108 { 00109 //CheckAnnoQuids(mask); 00110 00111 svm_problem* problem = new svm_problem; 00112 problem->l = mask->Size(); 00113 problem->y = new double[problem->l]; 00114 problem->x = new struct svm_node *[problem->l]; 00115 struct svm_node* nodes = new struct svm_node[problem->l*2]; 00116 for(int i=0 ; i<problem->l ; i++) 00117 { 00118 Quid q = mask->Get1(i); 00119 problem->y[i] = 0; 00120 if(mAnnotation->IsPositive(q)) 00121 problem->y[i] = 1; 00122 else if(mAnnotation->IsNegative(q)) 00123 problem->y[i] = -1; 00124 problem->x[i] = &nodes[i*2]; 00125 problem->x[i][0].index = 0; 00126 problem->x[i][0].value = mKernelQuids->GetIndex(q)+1; 00127 problem->x[i][1].index = -1; 00128 } 00129 return problem; 00130 }
Here is the call graph for this function:
|