MCPcopy Create free account
hub / github.com/antmachineintelligence/mtgbmcode / Split

Method Split

src/treelearner/voting_parallel_tree_learner.cpp:474–514  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

472
473template <typename TREELEARNER_T>
474void VotingParallelTreeLearner<TREELEARNER_T>::Split(Tree* tree, int best_Leaf, int* left_leaf, int* right_leaf) {
475 TREELEARNER_T::Split(tree, best_Leaf, left_leaf, right_leaf);
476 const SplitInfo& best_split_info = this->best_split_per_leaf_[best_Leaf];
477 // set the global number of data for leaves
478 global_data_count_in_leaf_[*left_leaf] = best_split_info.left_count;
479 global_data_count_in_leaf_[*right_leaf] = best_split_info.right_count;
480 auto p_left = smaller_leaf_splits_global_.get();
481 auto p_right = larger_leaf_splits_global_.get();
482 // init the global sumup info
483 if (best_split_info.left_count < best_split_info.right_count) {
484 smaller_leaf_splits_global_->Init(*left_leaf, this->data_partition_.get(),
485 best_split_info.left_sum_gradient,
486 best_split_info.left_sum_hessian);
487 larger_leaf_splits_global_->Init(*right_leaf, this->data_partition_.get(),
488 best_split_info.right_sum_gradient,
489 best_split_info.right_sum_hessian);
490 } else {
491 smaller_leaf_splits_global_->Init(*right_leaf, this->data_partition_.get(),
492 best_split_info.right_sum_gradient,
493 best_split_info.right_sum_hessian);
494 larger_leaf_splits_global_->Init(*left_leaf, this->data_partition_.get(),
495 best_split_info.left_sum_gradient,
496 best_split_info.left_sum_hessian);
497 p_left = larger_leaf_splits_global_.get();
498 p_right = smaller_leaf_splits_global_.get();
499 }
500 const int inner_feature_index = this->train_data_->InnerFeatureIndex(best_split_info.feature);
501 bool is_numerical_split = this->train_data_->FeatureBinMapper(inner_feature_index)->bin_type() == BinType::NumericalBin;
502 p_left->SetValueConstraint(best_split_info.min_constraint, best_split_info.max_constraint);
503 p_right->SetValueConstraint(best_split_info.min_constraint, best_split_info.max_constraint);
504 if (is_numerical_split) {
505 double mid = (best_split_info.left_output + best_split_info.right_output) / 2.0f;
506 if (best_split_info.monotone_type < 0) {
507 p_left->SetValueConstraint(mid, best_split_info.max_constraint);
508 p_right->SetValueConstraint(best_split_info.min_constraint, mid);
509 } else if (best_split_info.monotone_type > 0) {
510 p_left->SetValueConstraint(best_split_info.min_constraint, mid);
511 p_right->SetValueConstraint(mid, best_split_info.max_constraint);
512 }
513 }
514}
515
516// instantiate template classes, otherwise linker cannot find the code
517template class VotingParallelTreeLearner<GPUTreeLearner>;

Callers

nothing calls this directly

Calls 7

SplitFunction · 0.50
getMethod · 0.45
InitMethod · 0.45
InnerFeatureIndexMethod · 0.45
bin_typeMethod · 0.45
FeatureBinMapperMethod · 0.45
SetValueConstraintMethod · 0.45

Tested by

no test coverage detected