| 224 | } |
| 225 | |
| 226 | bool GBDT::SaveModelToIfElse(int num_iteration, const char* filename) const { |
| 227 | /*! \brief File to write models */ |
| 228 | std::ofstream output_file; |
| 229 | std::ifstream ifs(filename); |
| 230 | if (ifs.good()) { |
| 231 | std::string origin((std::istreambuf_iterator<char>(ifs)), |
| 232 | (std::istreambuf_iterator<char>())); |
| 233 | output_file.open(filename); |
| 234 | output_file << "#define USE_HARD_CODE 0" << '\n'; |
| 235 | output_file << "#ifndef USE_HARD_CODE" << '\n'; |
| 236 | output_file << origin << '\n'; |
| 237 | output_file << "#else" << '\n'; |
| 238 | output_file << ModelToIfElse(num_iteration); |
| 239 | output_file << "#endif" << '\n'; |
| 240 | } else { |
| 241 | output_file.open(filename); |
| 242 | output_file << ModelToIfElse(num_iteration); |
| 243 | } |
| 244 | |
| 245 | ifs.close(); |
| 246 | output_file.close(); |
| 247 | |
| 248 | return static_cast<bool>(output_file); |
| 249 | } |
| 250 | |
| 251 | std::string GBDT::SaveModelToString(int start_iteration, int num_iteration) const { |
| 252 | std::stringstream ss; |
no outgoing calls
no test coverage detected