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

Method Train

python-package/compile/src/boosting/gbdt.cpp:288–306  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

286}
287
288void GBDT::Train(int snapshot_freq, const std::string& model_output_path) {
289 bool is_finished = false;
290 auto start_time = std::chrono::steady_clock::now();
291 for (int iter = 0; iter < config_->num_iterations && !is_finished; ++iter) {
292 is_finished = TrainOneIter(nullptr, nullptr);
293 if (!is_finished) {
294 is_finished = EvalAndCheckEarlyStopping();
295 }
296 auto end_time = std::chrono::steady_clock::now();
297 // output used time per iteration
298 Log::Info("%f seconds elapsed, finished iteration %d", std::chrono::duration<double,
299 std::milli>(end_time - start_time) * 1e-3, iter + 1);
300 if (snapshot_freq > 0
301 && (iter + 1) % snapshot_freq == 0) {
302 std::string snapshot_out = model_output_path + ".snapshot_iter_" + std::to_string(iter + 1);
303 SaveModelToFile(0, -1, snapshot_out.c_str());
304 }
305 }
306}
307
308void GBDT::RefitTree(const std::vector<std::vector<int>>& tree_leaf_prediction) {
309 CHECK(tree_leaf_prediction.size() > 0);

Callers 3

TrainOneIterMethod · 0.45
TrainOneIter_oldMethod · 0.45
TrainOneIter_newMethod · 0.45

Calls 1

SaveModelToFileFunction · 0.70

Tested by

no test coverage detected