Commit f2c99ea4 authored by wxchan's avatar wxchan Committed by Guolin Ke
Browse files

[python] fix dump model with infinite threshold (#617)

* avoid threshold inf

* use __save_model_to_string for feature importance

* Revert "use __save_model_to_string for feature importance"

This reverts commit dca6a85fb3d89866eb56eb0c9ca103ada4d92b53.
parent 6c43f0e1
......@@ -82,7 +82,7 @@ int Tree::Split(int leaf, int feature, BinType bin_type, uint32_t threshold_bin,
}
threshold_in_bin_[new_node_idx] = threshold_bin;
threshold_[new_node_idx] = threshold_double;
threshold_[new_node_idx] = Common::AvoidInf(threshold_double);
split_gain_[new_node_idx] = Common::AvoidInf(gain);
// add two new leaves
left_child_[new_node_idx] = ~leaf;
......@@ -366,7 +366,7 @@ std::string Tree::NodeToJSON(int index) {
str_buf << "\"split_index\":" << index << "," << std::endl;
str_buf << "\"split_feature\":" << split_feature_[index] << "," << std::endl;
str_buf << "\"split_gain\":" << split_gain_[index] << "," << std::endl;
str_buf << "\"threshold\":" << threshold_[index] << "," << std::endl;
str_buf << "\"threshold\":" << Common::AvoidInf(threshold_[index]) << "," << std::endl;
str_buf << "\"decision_type\":\"" << Tree::GetDecisionTypeName(decision_type_[index]) << "\"," << std::endl;
str_buf << "\"default_value\":" << default_value_[index] << "," << std::endl;
str_buf << "\"internal_value\":" << internal_value_[index] << "," << std::endl;
......
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