Skip to content

Commit

Permalink
[ML] Write out forecasts predictions at "bucket time" rather than the…
Browse files Browse the repository at this point in the history
… actual times they are made in the time buckets (#332)
  • Loading branch information
tveasey authored Dec 7, 2018
1 parent f54a2c3 commit f55c717
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/model/CForecastDataSink.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#include <core/CLogger.h>
#include <core/CScopedRapidJsonPoolAllocator.h>

#include <maths/CIntegerTools.h>

#include <boost/bind.hpp>

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

0 comments on commit f55c717

Please sign in to comment.