webMethods

webMethods

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.

 View Only

TimeSeries Forecasting Weka - Java API

  • 1.  TimeSeries Forecasting Weka - Java API

    Posted Wed May 13, 2020 08:46 AM

    I am trying to implement TimeSeries Forecasting in a JavaService in webMethods. My Code is not working and i am completely lost so i would be glad if you could help me! FYI: I used this Tutorial.

    This is the Exception i get: com.wm.lang.flow.FlowException: weka.core.expressionlanguage.parser.Parser.getSymbolFactory()Ljava_cup/runtime/SymbolFactory;

    I just post the part which is not webMethods specific (normal Java):

    In the first part i am building an ARFF File which works fine. Because i saved the file and opened it with the weka Explorer and everything looks fine.

    The ARFF file looks like this:

    @relation Rel
    @attribute Count numeric
    @data
    2758
    2797
    2861
    575
    505
    4029

    (just with some more values (59 in total)) I want to forecast the next 3 values.

    Forecasting Part:

    
    // At the berginning i create and save the arff file, so i have an Instances 
    object called 'dataset'
    
    WekaForecaster forecaster = new WekaForecaster();
    try {
    forecaster.setFieldsToForecast("Count");
    } catch (Exception e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    }
    
    forecaster.setBaseForecaster(new GaussianProcesses());
    forecaster.getTSLagMaker().setTimeStampField("Date");
    forecaster.getTSLagMaker().setMinLag(1);
    forecaster.getTSLagMaker().setMaxLag(12);
    forecaster.getTSLagMaker().setAddMonthOfYear(true);
    forecaster.getTSLagMaker().setAddQuarterOfYear(true);
    
    PrintStream stream = null;
    List<List<NumericPrediction>> forecast = null;
    
    try {            
    stream = new PrintStream("./path/forecast.txt");
    forecaster.buildForecaster(dataset, stream);
    forecaster.primeForecaster(dataset);
    forecast = forecaster.forecast(3, dataset, stream);        
    } catch (Exception e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    }
    
    // output the predictions
    for (int i = 0; i < 3; i++) {
    List<NumericPrediction> predsAtStep = forecast.get(i);
    NumericPrediction predForTarget = predsAtStep.get(0);
    stream.print("" + predForTarget.predicted() + " ");
    stream.println();
    }

    The Java Code is hard to debug in webMethods, but it seems that
    forecaster.buildForecaster(dataset, stream); is causing the Exception.

    What am i missing?


    #webMethods-General
    #Integration-Server-and-ESB
    #webMethods