//main method to train the decision treee void Dectree_class::train(const cv::Mat& training_data, const cv::Mat& labels, int depth_thresh, unsigned int samples_thresh, int vars_per_node) { //---(1)initialize random generator if no external is given---// if(!is_ext_rng) { rng = cv::RNG(time(NULL)); //std::cout << "No ext rng" << std::endl; } //---(2)determine the number of classes based on the training data---// set_classes(labels); //std::cout << "Classes:\n" << classes << std::endl; //---(3)make a vector giving an id to each attribute---// set_attributes(training_data); //for debbugging /* for(std::vector<int>::iterator it = attributes.begin(); it != attributes.end(); ++it) std::cout << *it << " "; std::cout << std::endl; */ //---(4)verify constraints---// //maximum depth if(depth_thresh < 0) depth_limit = std::numeric_limits<int>::max(); else depth_limit = depth_thresh; //minimum samples min_samples = samples_thresh; //active variables if(attributes.size() < (unsigned)vars_per_node) active_vars = attributes.size(); else active_vars = vars_per_node; //maximum number of split fails max_split_fail = attributes.size(); //---(5)train the tree---// int depth = 1; int no_split_fail = 0; dbst.set_root(learn_dectree(cv::Mat(),labels, training_data, depth, no_split_fail)); find_depth(dbst.get_root()); //to find the real-true depth of the created tree }
inline char * finishconf(void) { static char buf[256]; char *ret; if (!new_MeLine || !new_MeLine->servername) return "Missing global block"; if ((ret = set_classes())) { ircsnprintf(buf, sizeof(buf), "Missing class block for referenced " "class '%s'", ret); return buf; } if (!new_ports) return "No ports defined"; return NULL; }