The resulting svm_problem can only be used for prediction, not for training. This code wants to be compatible to how libsvm handles kernel matrices so that's why we add an empty column in the matrix where libsvm normally has a column with indices for training. Definition at line 84 of file TrainDataSrcKernelMatrix.h. References Impala::Core::Array::Array2dTem< StorT, elemSize, ArithT >::CPB(), Impala::Core::Array::Array2dTem< StorT, elemSize, ArithT >::CW(), ILOG_VAR, and mMatrix. Referenced by MakeSvmProblem(). 00085 { 00086 ILOG_VAR(Core.Training.Svm.KernelSvmProblem); 00087 int vectorLength = mMatrix->CW(); 00088 svm_problem* problem = new svm_problem; 00089 problem->l = end - start; 00090 problem->y = new double[problem->l]; 00091 problem->x = new struct svm_node *[problem->l]; 00092 struct svm_node* nodes = new struct svm_node[problem->l*(2+vectorLength)]; 00093 for(int i=0 ; i<problem->l ; i++) 00094 { 00095 problem->y[i] = 0; 00096 problem->x[i] = &nodes[i*(vectorLength+2)]; 00097 problem->x[i][0].index = 0; 00098 problem->x[i][0].value = 0; // empty column expected by libsvm 00099 const double* values = mMatrix->CPB(0, start+i); 00100 int j; 00101 for(j=0 ; j<vectorLength ; j++) 00102 { 00103 problem->x[i][j+1].index = j+1; 00104 problem->x[i][j+1].value = values[j]; 00105 } 00106 problem->x[i][j+1].index = -1; 00107 } 00108 return problem; 00109 }
Here is the call graph for this function:
|