Hello sir,
I am currently working as Researcher and Developer and currently working with spark(new to spark), I want to implement time series models for that i use spark-ts examples and i am comfortable with java only so i tried to convert SingleSeriesARIMA.scala to .java but facing cast exception: ' org.apache.spark.api.java.JavaRDD cannot cast to org.apache.spark.mllib.linalg.vector'
When i am using
ARIMAModel arimamodel = ARIMA.fitmodel(1,0,1,(vector) ts, false, null, double[])
Where ts is defined JavaRDD<vector> and map with JavaRDD<string,vector> function.
Please give me positive response. Awaiting for response.
Thanks and Regards,
Devanshi Desai
Dataset<String> lines = session.read().textFile(args[0]);
Dataset<Double> doubleDataset = lines.map( line -> Double.parseDouble(line), Encoders.DOUBLE());
List<Double> doubleList = doubleDataset.collectAsList();
Double[] doubleArray = new Double[doubleList.size()];
doubleArray = doubleList.toArray(doubleArray);
double[] values = new double[doubleArray.length];
for (int i = 0; i < doubleArray.length; i++){
values[i] = doubleArray[i];
}
Vector tsVector = Vectors.dense(values);
System.out.println("TS vector:" + tsVector.toString());
ARIMAModel arimaModel = ARIMA.autoFit(tsVector, 1, 0, 1);
System.out.println("***ARIMA Model Coefficients ***");
for (double coefficient : arimaModel.coefficients()){
System.out.println("ARIMA model coefficient:" + coefficient);
}
Vector forecast = arimaModel.forecast(tsVector, 10);
System.out.println("ARIMA model forecast for next 10 observations:" + forecast);Hello,
I think here the problem that fitModel and autoFit is not showing as part of ARIMA Model.
In my case I used the same code which share by khattak. I found the proper result with using both fitModel as well as autoFit.
One more thing I used Spark 2.0.1 with scala 2.11.8 and java 1.8. So, please check version also.
Thanks and Regards,
Devanshi Desai