Friday 9 December 2016

Execute python data science packages from Java

Goal: To be able to execute python scripts from Java. Python Scripts include the use of python data science package like numpy, scipy, pandas.

Experiment 1: Jython with PythonInterpreter
Pros:
  1. Can run single-single python statement or python script
  2. Objects inside python can be excessed from java
Cons:
  1. Because it work on top of Jython distribution of python, Third party package(i.e. pandas, pymongo) based on Cpython might not be available
  2. JyNI project helps to add some third party Cpython type packages but it is in initial stage and import Data Science package like “Numpy”, “Panda” not supported.

Experiment 2: Jython with ScriptEngine
Skipping this part for now. It is very similar to “PythonInterpreter” approach and core problem still of supporting Cpython packages is still there.

Experiment 3: Java Embedded Python (Initial Experiment Successful)
Pros:
  1. Can work on default python packages
  2. Python Script processing
  3. Objects inside python can be excessed from java
  4. Third Party Cpython type package support
Cons:
  1. Complicated setup

Summary:
Jython:
Jython based solution might not work because java based python compiler does not support Cpython based packages like Pandas, Numpy etc. The best effort made to make Jython compatible with Cpython based package is via project “JyNi”. But Jyni also does not support Numpy or panda as of now.
JEP:

JEP is the best option for our use case so far. It works with Cpython interpreter which we use by default. It allow us to use all the packages/libraries supported by regular Cpython. Though it is tested successfully for importing packages like “pandas” and “nltk”, more test are required to check its boundary of compatibility.

4 comments:

  1. Hello Nishant,
    The Article on Execute python data science packages from Java is very informative give detail information about it. Thanks for Sharing the information about Data Science. data science consulting

    ReplyDelete
  2. Very nice blogs!!! i have to learning for lot of information for this sites…Sharing for wonderful information.Thanks for sharing this valuable information to our vision. You have posted a trust worthy blog keep sharing.

    Digital Marketing Training in Chennai

    Digital Marketing Course in Chennai


    ReplyDelete
  3. Sign up today for the intensive Python Course in Hyderabad program taught by experienced trainers from AI Patasala.
    Online Python Course in Hyderabad

    ReplyDelete
  4. I just wanted to comment in this blog to support you. Nice blog and informative content. Keep sharing more blogs with us. All the best for your future blogs.
    Data Science Course Training in Hyderabad

    ReplyDelete