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 85 of file TrainDataSrcKernelDistributed.h. References Impala::Core::Table::TableTem< Col1T, Col2T, Col3T, Col4T, Col5T, Col6T, Col7T, Col8T, Col9T >::Get1(), Impala::Core::Table::QuidTable::GetIndex(), Impala::Core::Table::AnnotationTable::IsNegative(), Impala::Core::Table::AnnotationTable::IsPositive(), Impala::Core::Training::TrainDataSrc::mAnnotation, mKernelQuids, and Impala::Core::Table::Table::Size(). Referenced by MakeSvmProblem(). 00086 { 00087 //CheckAnnoQuids(mask); 00088 00089 svm_problem* problem = new svm_problem; 00090 problem->l = mask->Size(); 00091 problem->y = new double[problem->l]; 00092 problem->x = new struct svm_node *[problem->l]; 00093 struct svm_node* nodes = new struct svm_node[problem->l*2]; 00094 for(int i=0 ; i<problem->l ; i++) 00095 { 00096 Quid q = mask->Get1(i); 00097 problem->y[i] = 0; 00098 if(mAnnotation->IsPositive(q)) 00099 problem->y[i] = 1; 00100 else if(mAnnotation->IsNegative(q)) 00101 problem->y[i] = -1; 00102 problem->x[i] = &nodes[i*2]; 00103 problem->x[i][0].index = 0; 00104 problem->x[i][0].value = mKernelQuids->GetIndex(q)+1; 00105 problem->x[i][1].index = -1; 00106 } 00107 return problem; 00108 }
Here is the call graph for this function:
|