how to call python and sklearn from matlab? [duplicate]
Asked Answered
M

1

-1

I need to call sklearn function on matlab. I have heard that there are some problems in calling numpy function and sklearn is based on numpy.

Is there any guide about that?

Macon answered 5/4, 2014 at 21:25 Comment(5)
A simple option would be to work in python instead of matlab ;)Stipe
More seriously, if you want to wrap python functions to be callable from your matlab code there are many ways to do it. What are the problems you have heard about?Stipe
I am forced to use matlab but the machine learning support of matlab is not very good and I really prefer to use python. This is why I am looking for some wrapper method. I need something of very stable. I have read a post which says that there are problem to import numpy in matlab. Any advices is welcomeMacon
I guess I don't understand what it means to 'import numpy in matlab'. Often what people do, size of the problem permitting, is to write data to a file in one environment, load and process it in the other, save the result and load it back in the first environment. This way both environments never interact directly.Stipe
I need to integrate the code in a production environment. I can not save data on a file every time. I need to call python function from matlab. Is this possible?Macon
I
1

For Python I see different solutions:

  • COM on Windows platforms. This requires to register an application, check if this is possible and allowed on the cluster.
  • XMLRPC or SOAP. You may need to use Java-Classes in Matlab, but as you already realised this is very simple. Verify that the cluster has a Java VM available, many run matlab without java.
  • You can embed python code into c/c++, which allows you to write mex functions which run c code: http://docs.python.org/2/extending/embedding.html
  • Create a .Net assembly using IronPython, matlab supports .net
Indefatigable answered 5/4, 2014 at 23:53 Comment(4)
according to #16172423 ironpython does not support sklearn so I have to exclude this option. what about the other 2 methods?Macon
sorry three methods COM,XMLRPC, embed c++Macon
Please read my answer, i never wrote anything about embedded c++Indefatigable
sorry by embedded I mean 'You can embed python code into c/c++'Macon

© 2022 - 2024 — McMap. All rights reserved.