MCPcopy Create free account
hub / github.com/antmachineintelligence/mtgbmcode / SaveModelToIfElse

Method SaveModelToIfElse

src/boosting/gbdt_model_text.cpp:226–249  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

224}
225
226bool 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
251std::string GBDT::SaveModelToString(int start_iteration, int num_iteration) const {
252 std::stringstream ss;

Callers 2

TrainMethod · 0.45
ConvertModelMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected