本文整理汇总了C++中Ensemble::writeEnsemble方法的典型用法代码示例。如果您正苦于以下问题:C++ Ensemble::writeEnsemble方法的具体用法?C++ Ensemble::writeEnsemble怎么用?C++ Ensemble::writeEnsemble使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Ensemble
的用法示例。
在下文中一共展示了Ensemble::writeEnsemble方法的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);
}
//.........这里部分代码省略.........