本文整理汇总了C++中Interaction::get_depth方法的典型用法代码示例。如果您正苦于以下问题:C++ Interaction::get_depth方法的具体用法?C++ Interaction::get_depth怎么用?C++ Interaction::get_depth使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Interaction
的用法示例。
在下文中一共展示了Interaction::get_depth方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: tree
// DFS search on tree. Places results in leaves parameter.
void tree(unordered_map<string,Interaction>& leaves,Rcpp::List const& datas, int cls,
vector<double> const& theta, vector<bool> const& factor,double epsilon_cont,double epsilon_cat,
int depth,int min_inter_sz,int branch,Generator& prng,double radius,bool es){
stack<Interaction, vector<Interaction> > frontier;
Rcpp::DataFrame class_data = Rcpp::as<Rcpp::DataFrame>(datas[cls]);
// Init root
int nb_class = datas.size();
vector<double> root_instance = random_instance(class_data,prng);
Interaction root(root_instance,factor,class_data,epsilon_cont,epsilon_cat,0,nb_class,radius);
frontier.push(root);
while(!frontier.empty()){
Interaction parent = frontier.top();
frontier.pop();
int c_depth = parent.get_depth();
int eff_branch = (c_depth <= 0) ? 1 : branch;
int nb_valid = 0; // number of valid children for this parent node
for(int i=0;i<eff_branch;++i){
int instance_nb = prng();
Interaction child(parent);
child.intersect(instance_nb,class_data);
child.set_depth(c_depth + 1);
if(child.size() >= min_inter_sz && child.check_sims(datas,theta,es)){ // child is valid
if(child.size() == min_inter_sz || child.get_depth() == depth){ // child is leaf
insert_interaction(leaves,child);
}
else{ // child is valid but not leaf
frontier.push(child);
}
nb_valid++;
}
}
if(nb_valid == 0) // If no child is valid, add parent as a leaf
insert_interaction(leaves,parent);
}
}
示例2: tree
// DFS search on tree. Places results in leaves parameter.
void tree(unordered_map<string,Interaction>& leaves,vector<Dataset> const& all_datasets, int cls,
vector<Ht_matrix> const& all_matrices,vector<double> const& theta,int depth,int split_nb,
int min_inter_sz,int branch,bool es,Generator& prng){
stack<Interaction, vector<Interaction> > frontier;
// Init root
int nb_class = all_matrices.size();
unordered_set<int> root_instance = random_instance(all_datasets[cls],prng);
Interaction root(root_instance,0,nb_class);
frontier.push(root);
while(!frontier.empty()){
Interaction parent = frontier.top();
frontier.pop();
int c_depth = parent.get_depth();
int eff_branch = (c_depth <= 0 || c_depth%split_nb != 0) ? 1 : branch;
int nb_valid = 0; // number of valid children for this parent node
for(int i=0;i<eff_branch;++i){
Interaction child(parent);
child.intersect(random_instance(all_datasets[cls],prng));
child.set_depth(c_depth + 1);
if(child.size() >= min_inter_sz && child.check_prev(all_matrices,theta,all_datasets,es)){ // child is valid
if(child.size() == min_inter_sz || child.get_depth() == depth){ // child is leaf
insert_interaction(leaves,child,all_matrices,theta,all_datasets);
}
else{ // child is valid but not leaf
frontier.push(child);
}
nb_valid++;
}
}
if(nb_valid == 0) // If no child is valid, add parent as leaf
insert_interaction(leaves,parent,all_matrices,theta,all_datasets);
}
}