本文整理汇总了C++中Forest::getMtry方法的典型用法代码示例。如果您正苦于以下问题:C++ Forest::getMtry方法的具体用法?C++ Forest::getMtry怎么用?C++ Forest::getMtry使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Forest
的用法示例。
在下文中一共展示了Forest::getMtry方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: rangerCpp
//.........这里部分代码省略.........
} else if (treetype == TREE_SURVIVAL) {
size_t status_varID = loaded_forest["status.varID"];
std::vector<std::vector<std::vector<double>> > chf = loaded_forest["chf"];
std::vector<double> unique_timepoints = loaded_forest["unique.death.times"];
((ForestSurvival*) forest)->loadForest(dependent_varID, num_trees, child_nodeIDs, split_varIDs, split_values,
status_varID, chf, unique_timepoints, is_ordered);
} else if (treetype == TREE_PROBABILITY) {
std::vector<double> class_values = loaded_forest["class.values"];
std::vector<std::vector<std::vector<double>>>terminal_class_counts =
loaded_forest["terminal.class.counts"];
((ForestProbability*) forest)->loadForest(dependent_varID, num_trees, child_nodeIDs, split_varIDs, split_values,
class_values, terminal_class_counts, is_ordered);
}
}
// Run Ranger
forest->run(false);
if (use_split_select_weights && importance_mode != IMP_NONE) {
*verbose_out
<< "Warning: Split select weights used. Variable importance measures are only comparable for variables with equal weights."
<< std::endl;
}
// Use first non-empty dimension of predictions
const std::vector<std::vector<std::vector<double>>>& predictions = forest->getPredictions();
if (predictions.size() == 1) {
if (predictions[0].size() == 1) {
result.push_back(forest->getPredictions()[0][0], "predictions");
} else {
result.push_back(forest->getPredictions()[0], "predictions");
}
} else {
result.push_back(forest->getPredictions(), "predictions");
}
// Return output
result.push_back(forest->getNumTrees(), "num.trees");
result.push_back(forest->getNumIndependentVariables(), "num.independent.variables");
if (treetype == TREE_SURVIVAL) {
ForestSurvival* temp = (ForestSurvival*) forest;
result.push_back(temp->getUniqueTimepoints(), "unique.death.times");
}
if (!verbose) {
std::stringstream temp;
temp << verbose_out->rdbuf();
result.push_back(temp.str(), "log");
}
if (!prediction_mode) {
result.push_back(forest->getMtry(), "mtry");
result.push_back(forest->getMinNodeSize(), "min.node.size");
if (importance_mode != IMP_NONE) {
result.push_back(forest->getVariableImportance(), "variable.importance");
}
result.push_back(forest->getOverallPredictionError(), "prediction.error");
}
if (keep_inbag) {
result.push_back(forest->getInbagCounts(), "inbag.counts");
}
// Save forest if needed
if (write_forest) {
Rcpp::List forest_object;
forest_object.push_back(forest->getDependentVarId(), "dependent.varID");
forest_object.push_back(forest->getNumTrees(), "num.trees");
forest_object.push_back(forest->getChildNodeIDs(), "child.nodeIDs");
forest_object.push_back(forest->getSplitVarIDs(), "split.varIDs");
forest_object.push_back(forest->getSplitValues(), "split.values");
forest_object.push_back(forest->getIsOrderedVariable(), "is.ordered");
if (treetype == TREE_CLASSIFICATION) {
ForestClassification* temp = (ForestClassification*) forest;
forest_object.push_back(temp->getClassValues(), "class.values");
} else if (treetype == TREE_PROBABILITY) {
ForestProbability* temp = (ForestProbability*) forest;
forest_object.push_back(temp->getClassValues(), "class.values");
forest_object.push_back(temp->getTerminalClassCounts(), "terminal.class.counts");
} else if (treetype == TREE_SURVIVAL) {
ForestSurvival* temp = (ForestSurvival*) forest;
forest_object.push_back(temp->getStatusVarId(), "status.varID");
forest_object.push_back(temp->getChf(), "chf");
forest_object.push_back(temp->getUniqueTimepoints(), "unique.death.times");
}
result.push_back(forest_object, "forest");
}
delete forest;
delete data;
} catch (std::exception& e) {
if (strcmp(e.what(), "User interrupt.") != 0) {
Rcpp::Rcerr << "Error: " << e.what() << " Ranger will EXIT now." << std::endl;
}
delete forest;
delete data;
return result;
}
return result;
}