本文整理汇总了C++中tree::getbots方法的典型用法代码示例。如果您正苦于以下问题:C++ tree::getbots方法的具体用法?C++ tree::getbots怎么用?C++ tree::getbots使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tree
的用法示例。
在下文中一共展示了tree::getbots方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: allsuff
//--------------------------------------------------
//get sufficients stats for all bottom nodes
void allsuff(std::vector<std::vector<double> >& X,
tree& x, xinfo& xi, dinfo& di, tree::npv& bnv,
std::vector<sinfo>& sv)
{
tree::tree_cp tbn; //the pointer to the bottom node for the current observations
size_t ni; //the index into vector of the current bottom node
double* xx = new double[di.n_cov];
double y; //current y
bnv.clear();
x.getbots(bnv);
typedef tree::npv::size_type bvsz;
bvsz nb = bnv.size();
sv.resize(nb);
std::map<tree::tree_cp,size_t> bnmap;
for(bvsz i=0;i!=bnv.size();i++) bnmap[bnv[i]]=i;
for(size_t i=0;i<di.n_samp;i++) {
for(size_t j=0;j<di.n_cov; j++){
xx[j] = X[i][j];
}
y=di.y[i];
tbn = x.bn(xx,xi);
ni = bnmap[tbn];
++(sv[ni].n);
sv[ni].sy += y;
sv[ni].sy2 += y*y;
}
}
示例2: getpb
//--------------------------------------------------
//compute prob of a birth, goodbots will contain all the good bottom nodes
double getpb(tree& t, xinfo& xi, pinfo& pi, tree::npv& goodbots)
{
double pb; //prob of birth to be returned
tree::npv bnv; //all the bottom nodes
t.getbots(bnv);
for(size_t i=0;i!=bnv.size();i++)
if(cansplit(bnv[i],xi)) goodbots.push_back(bnv[i]);
if(goodbots.size()==0) { //are there any bottom nodes you can split on?
pb=0.0;
} else {
if(t.treesize()==1) pb=1.0; //is there just one node?
else pb=pi.pb;
}
return pb;
}