1010#include < core/CLoopProgress.h>
1111#include < core/CPersistUtils.h>
1212#include < core/CProgramCounters.h>
13+ #include < core/CStopWatch.h>
1314
1415#include < maths/CBasicStatisticsPersist.h>
1516#include < maths/CBayesianOptimisation.h>
@@ -442,6 +443,10 @@ void CBoostedTreeImpl::train(core::CDataFrame& frame,
442443 LOG_TRACE (<< " Test loss = " << m_BestForestTestLoss);
443444
444445 } else if (m_CurrentRound < m_NumberRounds || m_BestForest.empty ()) {
446+ using TMeanVarAccumulator = CBasicStatistics::SSampleMeanVar<double >::TAccumulator;
447+ TMeanVarAccumulator timeAccumulator;
448+ core::CStopWatch stopWatch;
449+ stopWatch.start ();
445450
446451 // Hyperparameter optimisation loop.
447452
@@ -474,6 +479,8 @@ void CBoostedTreeImpl::train(core::CDataFrame& frame,
474479 LOG_TRACE (<< " Round " << m_CurrentRound << " state recording started" );
475480 this ->recordState (recordTrainStateCallback);
476481 LOG_TRACE (<< " Round " << m_CurrentRound << " state recording finished" );
482+
483+ timeAccumulator.add (static_cast <float >(stopWatch.lap ()));
477484 }
478485
479486 LOG_TRACE (<< " Test loss = " << m_BestForestTestLoss);
@@ -483,6 +490,12 @@ void CBoostedTreeImpl::train(core::CDataFrame& frame,
483490 m_BestForest = this ->trainForest (frame, this ->allTrainingRowsMask (), recordMemoryUsage);
484491 this ->recordState (recordTrainStateCallback);
485492
493+ timeAccumulator.add (static_cast <float >(stopWatch.stop ()));
494+
495+ LOG_INFO (<< " Training finished after " << m_CurrentRound << " iterations. Time per iteration in ms mean: "
496+ << CBasicStatistics::mean (timeAccumulator) << " std. dev: "
497+ << std::sqrt (CBasicStatistics::variance (timeAccumulator)));
498+
486499 core::CProgramCounters::counter (counter_t ::E_DFTPMTrainedForestNumberTrees) =
487500 m_BestForest.size ();
488501 }
@@ -1175,10 +1188,10 @@ void CBoostedTreeImpl::restoreBestHyperparameters() {
11751188 m_Eta = m_BestHyperparameters.eta ();
11761189 m_EtaGrowthRatePerTree = m_BestHyperparameters.etaGrowthRatePerTree ();
11771190 m_FeatureBagFraction = m_BestHyperparameters.featureBagFraction ();
1178- LOG_TRACE (<< " regularization* = " << m_Regularization.print ()
1179- << " , downsample factor* = " << m_DownsampleFactor << " , eta* = " << m_Eta
1180- << " , eta growth rate per tree* = " << m_EtaGrowthRatePerTree
1181- << " , feature bag fraction* = " << m_FeatureBagFraction);
1191+ LOG_INFO (<< " Best hyperparameters: regularization* = " << m_Regularization.print ()
1192+ << " , downsample factor* = " << m_DownsampleFactor << " , eta* = " << m_Eta
1193+ << " , eta growth rate per tree* = " << m_EtaGrowthRatePerTree
1194+ << " , feature bag fraction* = " << m_FeatureBagFraction);
11821195}
11831196
11841197std::size_t CBoostedTreeImpl::numberHyperparametersToTune () const {
0 commit comments