| 472 | |
| 473 | template <typename TREELEARNER_T> |
| 474 | void 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 |
| 517 | template class VotingParallelTreeLearner<GPUTreeLearner>; |
nothing calls this directly
no test coverage detected