当前位置: 首页>>代码示例>>C++>>正文


C++ DataManager::getIIGMats方法代码示例

本文整理汇总了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;
}
开发者ID:x9517536607,项目名称:Haarlike30,代码行数:61,代码来源:main.cpp


注:本文中的DataManager::getIIGMats方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。