Mandar Deshpande    Medium    Archive    GitHub    Resume    About

GSoC - II

Hi Guys!

It really awesome to tell you that I passed the first evaluations :D

  • Due to the issues faced in using PIMS,and since usage of PIMS would involve wrapping as many python-based functions as possible to allow individual usage in Scilab (which would be impractical to maintain on a large scale), it was decided to follow a different approach : Jupyter server-client.

  • This approach would allow direct usage of native python scripts without wrapping it for Scilab conversion, just the returned objects need to be converted (Eg. numpy arrays)

Following are the important points of this approach:

  1. Its essential to know that, we are not planning to have an interactive python environment within Scilab, as it would be unfeasible to manage so many libraries and versions in an efficient manner

  2. Python scripts will be written outside Scilab interface, and would be called to work only when their outputs or trained machine learning models need to be used in Scilab context.

  3. This would involve the following steps
    • Writing the required machine learning script and saving it as a ‘.py’ file.
    • Sending the ml script created to the python kernel running on jupyter server.
    • Once execution completes, passing back the python objects like regression model to Scilab and converting it to Scilab context.
    • This converted object can then be used for solving any required operation through Scilab like a differential equation.
  4. Two major parts of this approach are :

    [1] Passing the python script file to the jupyter server, and/or letting the python kernel to know where this file exists

    [2] Conversion of python objects to Scilab compatible form

Part [1] involves, passing the path of the script file to the jupyter server so that the python kernel can execute it. This can be achieved through python code for transferring/copying the script file to python kernel path.

Even if we decide to follow the PIMS approach or continue working on this jupyter server method, we would be required to handle part [2].


An illustration of Jupyter-Client Approach for machine learning in Scilab

  • With detailed discussions with Philippe Saade, it was decided first to have the coefficient arrays from the trained model to be transferred to Scilab side as matrices. Once converted, the coefficient matrix can be used for predicting test values or solving other Scilab operations like differential equation.

  • I took a simple linear regression example, trained the model on both Scilab side (using PIMS) and on python side.

  • Used matplotlib to plot prediction vs input data on python side; and used the coefficient matrix on Scilab side to make a similar plot, using a user-defined ‘predict’ method for linear_model.

  • I compared the two plots on both python and scikit-learn side, and they exactly the same. Find the attached images below:

Comparison of prediction results on Python and Scilab side

  • There are issues related to network port declaration currently with the Jupyter_client. Working along Simon Marchetto too resolve them.