Hitachi Vantara Pentaho Community Forums
Results 1 to 2 of 2

Thread: Weka Programmatically Get Dates along with Predicted values

  1. #1

    Question Weka Programmatically Get Dates along with Predicted values


    I have to write some code on top of WEKA time series forecasting. I am able to get predicted values using sample code explained here. This code works perfect to provide me values, however it does not say for what all dates it is predicting the values. Could you please suggest how should I get those dates.


  2. #2
    Join Date
    Aug 2006


    The class that handles all the data transformations and date manipulation behind the scenes is called TSLagMaker. WekaForecaster uses an instance of this internally and you can get it via the getTSLagMaker() accessor method. If you are using a true date-based time stamp (and not an artificial time stamp) then you can get the corresponding date values for the predicted values like so (IMPORTANT - make sure you get call get getCurrentTimeStampValue() *after* priming but *before* generating the forecast):

    TSLagMaker lagMaker = myWekaForecaster.getTSLagMaker();
    double lastTimeFromPrime = lagMaker.getCurrentTimeStampValue();
    double currentTime = lastTimeFromPrime;

    // this will advance the current time to correspond to the first forecasted values (i.e. 1-step ahead).
    // calling a second time will advance to correspond to the 2-step ahead forecast, and so on.
    currentTime = lagMaker.advanceSuppliedTimeValue(currentTime);

    The double value used here is the Java number of milliseconds elapsed since the epoch. You can cast it to a long and construct a Date object.

    Hope this helps.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Privacy Policy | Legal Notices | Safe Harbor Privacy Policy

Copyright © 2005 - 2017 Pentaho Corporation. All Rights Reserved.