Skip to content

Commit dde0e18

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

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

lib/model/CForecastDataSink.cc

Lines changed: 7 additions & 3 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>
@@ -221,9 +223,11 @@ void CForecastDataSink::push(const maths::SErrorBar errorBar,
221223
m_Writer.addIntFieldToObj(DETECTOR_INDEX, detectorIndex, doc);
222224
m_Writer.addStringFieldReferenceToObj(FORECAST_ID, m_ForecastId, doc);
223225
m_Writer.addStringFieldCopyToObj(FEATURE, feature, doc, true);
224-
225-
// time is in Java format - milliseconds since the epoch
226-
m_Writer.addTimeFieldToObj(TIMESTAMP, errorBar.s_Time, doc);
226+
// Time is in Java format - milliseconds since the epoch. Note this
227+
// matches the Java notion of "bucket time" which is defined as the
228+
// start of the bucket containing the forecast time.
229+
core_t::TTime time{maths::CIntegerTools::floor(errorBar.s_Time, errorBar.s_BucketLength)};
230+
m_Writer.addTimeFieldToObj(TIMESTAMP, time, doc);
227231
m_Writer.addIntFieldToObj(BUCKET_SPAN, errorBar.s_BucketLength, doc);
228232
if (!partitionFieldName.empty()) {
229233
m_Writer.addStringFieldCopyToObj(PARTITION_FIELD_NAME, partitionFieldName, doc);

0 commit comments

Comments
 (0)