本文整理汇总了C++中CvRTrees::getVarImportance方法的典型用法代码示例。如果您正苦于以下问题:C++ CvRTrees::getVarImportance方法的具体用法?C++ CvRTrees::getVarImportance怎么用?C++ CvRTrees::getVarImportance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CvRTrees
的用法示例。
在下文中一共展示了CvRTrees::getVarImportance方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
//.........这里部分代码省略.........
cout << endl;
}
*/
// Create type mask
Int_t var[VARS + 1];
for (Int_t i = 0; i < VARS; i++)
var[i] = CV_VAR_ORDERED;
var[VARS] = CV_VAR_CATEGORICAL;
Mat var_type(VARS + 1, 1, CV_32SC1, var);
var_type.convertTo(var_type, CV_8SC1); // Convert to 8-bit ints
// Create missing data mask
Int_t miss_t[TRAIN][VARS];
for (Int_t i = 0; i < TRAIN; i++)
{
for (Int_t j = 0; j < VARS; j++)
miss_t[i][j] = 0;
}
Mat missing_data_mask(TRAIN, VARS, CV_32SC1, miss_t);
missing_data_mask.convertTo(missing_data_mask, CV_8UC1);
// Create indices
Mat var_idx = Mat::ones(VARS, 1, CV_8UC1);
Mat sample_idx = Mat::ones(TRAIN, 1, CV_8UC1);
// Train forest, print variable importance (if used)
cout << "Trees: " << max_trees << endl;
cout << "Depth: " << max_depth << endl;
cout << "m: " << nactive_vars << endl;
CvRTrees forest;
forest.train(train_data, tflag, responses, var_idx, sample_idx, var_type, missing_data_mask, CvRTParams(max_depth, min_sample_count, regression_accuracy, use_surrogates, max_categories, priors, calc_var_importance, nactive_vars, max_trees, forest_accuracy, termcrit_type));
if (calc_var_importance)
{
Mat imp = forest.getVarImportance();
cout << endl << imp << endl << endl;
}
// Create solving array and data mask
Int_t solve_good = event[0] - train_good;
Int_t solve_bad = event[1] - train_bad;
const Int_t SOLVE = solve_good + solve_bad;
Int_t flag[SOLVE];
Float_t solve[SOLVE][VARS];
for (Int_t i = 0; i < solve_good; i++)
{
tree[0]->GetEvent(i + train_good);
flag[i] = 0;
// solve[i][0] = tibHits[0];
// solve[i][1] = tidHits[1];
// solve[i][2] = tobHits[1];
// solve[i][3] = tecHits[0];
solve[i][0] = ptR[0];
solve[i][1] = etaR[0];
solve[i][2] = phiR[0];
solve[i][3] = foundR[0];
}
for (Int_t i = 0; i < solve_bad; i++)
{
tree[1]->GetEvent(i + train_bad);
flag[i + solve_good] = 1;
// solve[i + solve_good][0] = tibHits[1];
// solve[i + solve_good][1] = tidHits[1];
// solve[i + solve_good][2] = tobHits[1];
// solve[i + solve_good][3] = tecHits[1];
solve[i + solve_good][0] = ptR[1];
solve[i + solve_good][1] = etaR[1];