Unverified Commit e6de39a7 authored by Nikita Titov's avatar Nikita Titov Committed by GitHub
Browse files

fix inf in json model dump (#2940)

parent 7c2958cd
......@@ -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], ':');
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment