Definition at line 26 of file mainConceptSet.cpp. References Impala::Core::Feature::WeightedFeatureList::Add(), Impala::Core::Table::TableTem< Col1T, Col2T, Col3T, Col4T, Col5T, Col6T, Col7T, Col8T, Col9T >::Add(), Impala::atol(), Impala::Core::Array::Array2dTem< StorT, elemSize, ArithT >::CH(), Impala::Core::Array::Array2dTem< StorT, elemSize, ArithT >::CPB(), Impala::Core::Training::FikSvm::CreateSvm(), Impala::Core::Table::TableTem< Col1T, Col2T, Col3T, Col4T, Col5T, Col6T, Col7T, Col8T, Col9T >::Get1(), Impala::CmdOptions::GetArg(), Impala::Core::Matrix::DistributedAccess::GetColumnQuids(), Impala::Core::Matrix::DistributedAccess::GetFeature(), Impala::Core::Database::RawDataSet::GetLocator(), Impala::CmdOptions::GetNrArg(), Impala::Core::Matrix::DistributedAccess::GetNrFeatures(), Impala::CmdOptions::GetString(), Impala::Core::Matrix::DistributedAccess::GetWeight(), ILOG_ERROR, ILOG_INFO, ILOG_VAR, Impala::MakeString(), and Impala::Core::Matrix::SetColumn(). Referenced by mainConceptSet(). 00028 { 00029 ILOG_VAR(Impala.Application.ConceptSet.DoApproxFikModel); 00030 if (options.GetNrArg() < curArg + 3) 00031 { 00032 ILOG_ERROR("Need more arguments"); 00033 return; 00034 } 00035 String model = options.GetArg(curArg++); 00036 String kernel = options.GetArg(curArg++); 00037 int nrBins = atol(options.GetArg(curArg++)); 00038 String indexCat = options.GetString("featureIndexCat"); 00039 00040 String fikModel = model + "-approx-" + MakeString(nrBins); 00041 ModelLocator fikLoc(dataSet->GetLocator(), conceptSet, fikModel, kernel, 00042 concept); 00043 if (FikSvmRepository().Exists(fikLoc)) 00044 { 00045 ILOG_INFO("Model for " << concept << " already exists, skipping."); 00046 return; 00047 } 00048 00049 KernelMatrixLocator daLoc(dataSet->GetLocator(), true, "", "", model, 00050 kernel, ""); 00051 daLoc.SetStartNode(0); 00052 daLoc.SetNodeCount(Link::Mpi::NrProcs()); 00053 daLoc.SetDoParts(0); 00054 daLoc.SetFeatureIndexCat(indexCat); 00055 DistributedAccess* da = DistributedAccessRepository().Get(daLoc); 00056 ModelLocator mLoc(dataSet->GetLocator(), conceptSet, model, kernel, concept); 00057 Svm* svm = SvmRepository().Get(mLoc); 00058 const svm_model* svmModel = svm->GetModel(); 00059 int nrSV = svmModel->l; 00060 double rho = svmModel->rho[0]; 00061 ILOG_INFO("nr_sv = " << nrSV); 00062 double* coeffs = svmModel->sv_coef[0]; 00063 QuidTable* kernelQuids = da->GetColumnQuids(); 00064 QuidTable svQuids; 00065 for (int i=0 ; i<nrSV ; i++) 00066 { 00067 svm_node* node = svmModel->SV[i]; 00068 int idx = node->value - 1; 00069 Quid q = kernelQuids->Get1(idx); 00070 svQuids.Add(q); 00071 } 00072 00073 Mat* mat = 0; 00074 int nrFeatures = da->GetNrFeatures(); 00075 WeightedFeatureList features; 00076 for (int i=0 ; i<nrFeatures ; i++) 00077 features.Add(da->GetFeature(i), da->GetWeight(i)); 00078 Real64 probA = svmModel->probA[0]; 00079 Real64 probB = svmModel->probB[0]; 00080 int probIndex = (svmModel->label[1] == 1) ? 1 : 0; 00081 FikSvm fikSvm(features, nrBins, nrSV, rho, probA, probB, probIndex); 00082 for (int i=0 ; i<nrFeatures ; i++) 00083 { 00084 ILOG_INFO("feature = " << da->GetFeature(i)); 00085 FeatureLocator fLoc(dataSet->GetLocator(), false, true, indexCat, 00086 da->GetFeature(i), ""); 00087 FeatureTable* tab = FeatureTableRepository().Get(fLoc); 00088 int featDim = tab->GetFeatureVectorLength(); 00089 if ((mat == 0) || (mat->CH() != featDim)) 00090 { 00091 ILOG_INFO("featDim = " << featDim); 00092 if (mat) 00093 delete mat; 00094 mat = MatCreate<Mat>(featDim, nrSV); 00095 } 00096 for (int sv=0 ; sv<nrSV ; sv++) 00097 { 00098 Quid q = svQuids.Get1(sv); 00099 SetColumn(mat, sv, tab->FindFeature(q)); 00100 } 00101 fikSvm.CreateSvm(featDim, coeffs, mat->CPB()); 00102 //fikSvm.Dump(i, 3); 00103 delete tab; 00104 } 00105 ILOG_INFO("Saving in " << fikLoc); 00106 FikSvmRepository().Add(fikLoc, &fikSvm); 00107 delete mat; 00108 delete svm; 00109 delete da; 00110 }
Here is the call graph for this function: ![]()
|