JRI and ARIMA integration

2019-08-31 17:18发布

问题:

I have one last question, but I really need help on this one. The very last thing for my project is that I have to make ARIMA, to work under JRI. All everything is working, but one little piece of code is not working properly. Here's the code:

                            re.eval("library(forecast);");
            re.assign("y", arrayStr);
                re.eval("datats<-y;");


                    re.eval("arima<-auto.arima(datats);");
                    re.eval("fcast<-forecast(arima);");
                REXP fs = re.eval("summary(fcast);");

                    double[] forecast = fs.asDoubleArray();
                    for(int i=0; i<forecast.length; i++)
                    System.out.println(forecast[i]);

I've tried this one too, but it's not working too.

re.eval("sensor<-ts(y,frequency=365)");
            re.eval("library(forecast);");
            //re.eval("sink(\"sink-examp.txt\");");
            //re.eval("is.ts(datats);");
            //re.eval("sink()");
            re.eval("fit <- auto.arima(sensor,D=1);");
            re.eval("LH.pred <- forecast(fit,h=20)");
            //re.eval("sink(\"sink-examp.txt\");");
            //re.eval("sink(summary(test1))");
            REXP result = re.eval("summary(LH.pred)");
            System.out.println(result.asString());

Any advice will be appreciated. Thanks in advance!

回答1:

The reason why this is happening is: You CANNOT transfer a lot of data between both languages. I was supposed to use Oracle DB to move the data without any lost pieces of information.



标签: java jri