本文整理汇总了C++中DataManager::getIIGMats方法的典型用法代码示例。如果您正苦于以下问题:C++ DataManager::getIIGMats方法的具体用法?C++ DataManager::getIIGMats怎么用?C++ DataManager::getIIGMats使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataManager
的用法示例。
在下文中一共展示了DataManager::getIIGMats方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: K_fold_cross_validation
void K_fold_cross_validation(int k, DataManager &posData, DataManager &negData)
{
time_t start;
int Tp = 0, Fp = 0, Fn = 0, Tn = 0;
vector<Mat> * posIIGs = posData.getIIGMats();
vector<Mat> * negIIGs = negData.getIIGMats();
vector<vector<Mat>> subPosIIGs(k);
vector<vector<Mat>> subNegIIGs(k);
for (int i = 0; i < posIIGs->size(); i++)
{
subPosIIGs[i % k].push_back((*posIIGs)[i]);
}
for (int i = 0; i < negIIGs->size(); i++)
{
subNegIIGs[i % k].push_back((*negIIGs)[i]);
}
posIIGs->clear();
negIIGs->clear();
for (int l = 0; l < k; l++)
{
std::cerr << "K = " << l << std::endl;
std::cerr << "Training ... " << std::endl;
start = clock();
vector<Mat> trainPos;
vector<Mat> trainNeg;
for (int j = 0; j < k; j++)
{
if (l != j)
{
trainPos.insert(trainPos.end(), subPosIIGs[j].begin(), subPosIIGs[j].end());
trainNeg.insert(trainNeg.end(), subNegIIGs[j].begin(), subNegIIGs[j].end());
}
}
TrainingManager tm(trainPos, trainNeg);
cerr << (clock() - start) / 1000.0 << "s" << endl;
start = clock();
//
ADA<float> ada;
std::cerr << "Boosting ... " << std::endl;
ClassificationResults weights = ada.ada_boost(tm.getAllfeature()->size(), *(tm.getRM()), *(tm.getLabels()), 100);
std::cerr << "Done " << std::endl;
cerr << (clock() - start) / 1000.0 << "s" << endl;
start = clock();
std::cerr << "Construct model ... " << std::endl;
saveStrongClassfier(*(tm.getAllfeature()), weights);
cerr << (clock() - start) / 1000.0 << "s" << endl;
start = clock();
std::cerr << "Testing ... " << std::endl;
//allfeature.clear();
testing(subPosIIGs[l], subNegIIGs[l], Tp, Fp, Fn, Tn);
cerr << (clock() - start) / 1000.0 << "s" << endl;
cerr << endl;
}
cerr << "Final acc:" << (float)(Tp + Tn) / (Tp + Fn + Fp + Tn) << endl;
cerr << "Final tpr:" << (float)Tp / (Tp + Fn) << endl;
cerr << "Final fpr:" << (float)Fp / (Tn + Fp) << endl;
cerr << endl;
}