SGVector<float64_t> CExactInferenceMethod::get_diagonal_vector() { check_members(); float64_t m_sigma = dynamic_cast<CGaussianLikelihood*>(m_model)->get_sigma(); SGVector<float64_t> result = SGVector<float64_t>(m_features->get_num_vectors()); result.fill_vector(result.vector, m_features->get_num_vectors(), 1.0/m_sigma); return result; }
void CCARTree::prune_using_test_dataset(CDenseFeatures<float64_t>* feats, CLabels* gnd_truth, SGVector<float64_t> weights) { if (weights.vlen==0) { weights=SGVector<float64_t>(feats->get_num_vectors()); weights.fill_vector(weights.vector,weights.vlen,1); } CDynamicObjectArray* pruned_trees=prune_tree(this); int32_t min_index=0; float64_t min_error=CMath::MAX_REAL_NUMBER; for (int32_t i=0;i<m_alphas->get_num_elements();i++) { CSGObject* element=pruned_trees->get_element(i); bnode_t* root=NULL; if (element!=NULL) root=dynamic_cast<bnode_t*>(element); else SG_ERROR("%d element is NULL\n",i); CLabels* labels=apply_from_current_node(feats, root); float64_t error=compute_error(labels,gnd_truth,weights); if (error<min_error) { min_index=i; min_error=error; } SG_UNREF(labels); SG_UNREF(element); } CSGObject* element=pruned_trees->get_element(min_index); bnode_t* root=NULL; if (element!=NULL) root=dynamic_cast<bnode_t*>(element); else SG_ERROR("%d element is NULL\n",min_index); this->set_root(root); SG_UNREF(pruned_trees); SG_UNREF(element); }