Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[cpp] fix: to_if_else missing check for threshold when missing_type is not none #6818

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fix: cpp to_if_else missing check for threshold when missing_type is …
…not none
  • Loading branch information
wuciting committed Feb 7, 2025
commit cdce21786828d5a2d8d1a28603d57afa5339841a
11 changes: 6 additions & 5 deletions src/io/tree.cpp
Original file line number Diff line number Diff line change
@@ -531,19 +531,20 @@ std::string Tree::NumericalDecisionIfElse(int node) const {
}
if (missing_type == MissingType::Zero) {
if (default_left) {
str_buf << "if (Tree::IsZero(fval)) {";
str_buf << "if (Tree::IsZero(fval) || ";
} else {
str_buf << "if (!Tree::IsZero(fval)) {";
str_buf << "if (!Tree::IsZero(fval) && ";
}
} else if (missing_type == MissingType::NaN) {
if (default_left) {
str_buf << "if (std::isnan(fval)) {";
str_buf << "if (std::isnan(fval) || ";
} else {
str_buf << "if (!std::isnan(fval)) {";
str_buf << "if (!std::isnan(fval) && ";
}
} else {
str_buf << "if (fval <= " << threshold_[node] << ") {";
str_buf << "if (";
}
str_buf << "fval <= " << threshold_[node] << ") {";
return str_buf.str();
}