Skip to content

Commit f55c717

Browse files
authored
[ML] Write out forecasts predictions at "bucket time" rather than the actual times they are made in the time buckets (#332)
1 parent f54a2c3 commit f55c717

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

lib/model/CForecastDataSink.cc

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
#include <core/CLogger.h>
1010
#include <core/CScopedRapidJsonPoolAllocator.h>
1111

12+
#include <maths/CIntegerTools.h>
13+
1214
#include <boost/bind.hpp>
1315

1416
#include <vector>
@@ -230,8 +232,11 @@ void CForecastDataSink::push(const maths::SErrorBar errorBar,
230232
m_Writer.addStringFieldReferenceToObj(FORECAST_ALIAS, m_ForecastAlias, doc);
231233
}
232234
m_Writer.addStringFieldCopyToObj(FEATURE, feature, doc, true);
233-
// time is in Java format - milliseconds since the epoch
234-
m_Writer.addTimeFieldToObj(TIMESTAMP, errorBar.s_Time, doc);
235+
// Time is in Java format - milliseconds since the epoch. Note this
236+
// matches the Java notion of "bucket time" which is defined as the
237+
// start of the bucket containing the forecast time.
238+
core_t::TTime time{maths::CIntegerTools::floor(errorBar.s_Time, errorBar.s_BucketLength)};
239+
m_Writer.addTimeFieldToObj(TIMESTAMP, time, doc);
235240
m_Writer.addIntFieldToObj(BUCKET_SPAN, errorBar.s_BucketLength, doc);
236241
if (!partitionFieldName.empty()) {
237242
m_Writer.addStringFieldCopyToObj(PARTITION_FIELD_NAME, partitionFieldName, doc);

0 commit comments

Comments
 (0)