Skip to content

Commit

Permalink
fix inf in json model dump (#2940)
Browse files Browse the repository at this point in the history
  • Loading branch information
StrikerRUS authored Mar 30, 2020
1 parent 7c2958c commit e6de39a
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/boosting/gbdt_model_text.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,12 @@ std::string GBDT::DumpModel(int start_iteration, int num_iteration) const {
if (strs[0][0] == '[') {
strs[0].erase(0, 1); // remove '['
strs[1].erase(strs[1].size() - 1); // remove ']'
json_str_buf << "{\"min_value\":" << strs[0] << ",";
json_str_buf << "\"max_value\":" << strs[1] << ",";
double max_, min_;
Common::Atof(strs[0].c_str(), &min_);
Common::Atof(strs[1].c_str(), &max_);
json_str_buf << std::setprecision(std::numeric_limits<double>::digits10 + 2);
json_str_buf << "{\"min_value\":" << Common::AvoidInf(min_) << ",";
json_str_buf << "\"max_value\":" << Common::AvoidInf(max_) << ",";
json_str_buf << "\"values\":[]}";
} else if (strs[0] != "none") { // categorical feature
auto vals = Common::StringToArray<int>(feature_infos_[i], ':');
Expand Down

0 comments on commit e6de39a

Please sign in to comment.