从 Java 调用 R - RCaller 的更快替代方案
我尝试使用 RCaller 2.0 从 Java 调用 R 函数,经过几次尝试后我成功了。集成非常简单,但 RCaller 在运行时有点慢。我担心 RCaller 2.0
不适合我的应用程序,因为我必须重复调用同一脚本数千次,并且该库引入的延迟对于我的需求来说是不可接受的。
是否有更快(就运行时执行时间而言)的替代方案来从 Java 调用 R 脚本?
I tried RCaller 2.0
to call R functions from Java and I managed to make it work after a few tries. Integration was pretty easy but RCaller is kinda slow at runtime. I'm afraid that RCaller 2.0
won't be suitable for my application since I have to repeatedly call the same script thousands of times and the latency introduced by this library is unacceptable for my needs.
Is there a faster (in terms of run-time execution time) alternative for calling R scripts from Java?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
Rcaller 在 2.1 版本中进行了许多性能改进。现在,它支持使用单个 R 进程在循环中将命令传递给 R。也就是说,初始化过程之后不再有系统调用。
Rcaller has many performance improvements that came with the version 2.1. It now supports passing commands to R in a loop using a single R process. That is, there is no more system calls after the initializing process.
查看 RCaller 源代码树中的测试文件:
https://code.google .com/p/rcaller/source/browse/RCaller/src/test/java/rcaller/RunOnlineTest.java
此测试文件包含在单个 R 进程上运行的顺序命令。据说这种方式很快。
Have a look at the test file in RCaller source tree:
https://code.google.com/p/rcaller/source/browse/RCaller/src/test/java/rcaller/RunOnlineTest.java
This test file includes sequential commands that run on a single R process. This way is said to be fast.
有什么方法可以将一些迭代推入 R 中,从而减少调用它的频率吗?也许您可以传入一组数据,并运行一组要运行的脚本,现在您可以将它们一一传递。
Is there any way to push some of the iteration over into R, so that you're calling it much less often? Maybe you can pass in an array of data, with an array of scripts to run, where you're passing them in one by one now.
尝试 Renjin,至少看起来相当快!
Try Renjin, it seems pretty fast at least!