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


C++ Ensemble::test方法代码示例

本文整理汇总了C++中Ensemble::test方法的典型用法代码示例。如果您正苦于以下问题:C++ Ensemble::test方法的具体用法?C++ Ensemble::test怎么用?C++ Ensemble::test使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Ensemble的用法示例。


在下文中一共展示了Ensemble::test方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int main(int argc, char* argv[]) {

	/*********************
	** Parameters
	*********************/	
	string ipData;	
	string ipLabels;
	string ensembleFile;
	string testData;
	string opFileName;

	// training parameters
	int numTrees;
	int treeDepth; // 0 = 1 node, 1 = 3 nodes, 2 = 7 ...
	int numDimTrials;//num of dims to try < dim
	int numThreshTrials; // num of thresholds at each dimension to try
	float bagProb; // probability of sample landing in bag
	int minNoOFExsAtNode; // stop growing tree if num of examples at node equals this value

	srand ( time(NULL) );
	clock_t init;
	Ensemble trees;	


	/*********************
	** Set up parameters
	*********************/	
	bool trainingNew = false;
	if (argc == 12) {// training new forest
		
		trainingNew = true;
		numTrees = atoi(argv[1]);
		treeDepth = atoi(argv[2]);
		numDimTrials = atoi(argv[3]);
		numThreshTrials = atoi(argv[4]);
		bagProb = (float)atoi(argv[5])/100.0;
		minNoOFExsAtNode = atoi(argv[6]);

		cout << "** " << bagProb << " " << treeDepth << endl; 
		ipData = argv[7];
		ipLabels = argv[8];
		testData = argv[9];
		opFileName =  argv[10];
		ensembleFile =  argv[11];

	}
	else if (argc == 4) {// loading existing forest

		testData = argv[1];
		opFileName =  argv[2];
		ensembleFile =  argv[3];

	}
	else {// exit if invalid number of agruments passed

		displayUsage();
		return 0;
	}
	

	/*********************
	** Training
	*********************/
	if (trainingNew) {

		/*********************
		** Load training data
		*********************/		
		init=clock();
		cout << endl << "***************************" << endl << "Loading data" << endl << endl;			
		Matrix2df data;
		loadData(ipData, data);	
		Matrix2df labels;
		loadData(ipLabels, labels);
		cout << "loading data time " << (double)(clock()-init) / ((double)CLOCKS_PER_SEC) << " sec" << endl;
		

		/*********************
		** Training
		*********************/
		init=clock();
		cout << endl << "***************************" << endl << "Training" << endl;	
		trees.setParams(numTrees, treeDepth, data.cols, labels.cols);		
		trees.train(data, labels, numDimTrials, numThreshTrials, bagProb, minNoOFExsAtNode);
		cout << "\r                                      " << endl;
		cout << "training time " << (double)(clock()-init) / ((double)CLOCKS_PER_SEC) << " sec" << endl;

		/*********************
		** Save forest
		*********************/	
		trees.writeEnsemble(ensembleFile);
	}
	else {

		/*********************
		** Load forest
		*********************/		
		trees.loadEnsemble(ensembleFile);
	}

//.........这里部分代码省略.........
开发者ID:ahmadh84,项目名称:occlusiontracking,代码行数:101,代码来源:forestTest.cpp


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