1

I have used the example given in https://wiki.pentaho.com/display/DATAMINING/Time+Series+Analysis+and+Forecasting+with+Weka for time series forecasting in Weka. But I'm getting a NullPointerException

java.lang.NullPointerException  
at weka.filters.supervised.attribute.TSLagMaker.setupPeriodicMaps(TSLagMaker.java:2372)
at weka.filters.supervised.attribute.TSLagMaker.getTransformedData(TSLagMaker.java:2604) 
at weka.filters.supervised.attribute.TSLagMaker.getTransformedData(TSLagMaker.java:2585)    
at weka.classifiers.timeseries.WekaForecaster.buildForecaster(WekaForecaster.java:1092)
at com.project.timeseries.forecast.main(Forecast.java:54)

I have converted my CSV file to ARFF and the ARFF data looks like this

@relation Test

@attribute DateCreated {1/21/17,1/22/17,1/23/17,...}    
@attribute Quantity numeric

@data
1/21/17,39
1/22/17,10
1/23/17,36
...

I have only changed the following fields in the code given in the previous link

forecaster.setFieldsToForecast("Quantity");

forecaster.setBaseForecaster(new SMOreg());

  forecaster.getTSLagMaker().setPrimaryPeriodicFieldName("Date"); // date time stamp
  forecaster.getTSLagMaker().setMinLag(1);
  forecaster.getTSLagMaker().setMaxLag(12); // monthly data
  • It's going to be difficult to figure this out without seeing some code. Can you post a [minimal, complete, verifiable example](https://stackoverflow.com/help/mcve)? Or, you might be able to figure it out yourself with tips from the answers on the [canonical NPE question](https://stackoverflow.com/q/218384/18356). – shoover May 17 '18 at 18:13
  • In the file, the attribute is called `DateCreated`. In the source code, you are referring to it as `Date`. Rename the attribute in the ARFF file, or change the code to `forecaster.getTSLagMaker().setPrimaryPeriodicFieldName("DateCreated");` – Marco13 May 17 '18 at 18:58
  • @Marco13 it worked thanks! –  May 18 '18 at 09:25

0 Answers0