Python, Matlab and AI question

D

dataangel

I'm a student who's considering doing a project for a Machine Learning
class on pathing (bots learning to run through a maze). The language
primarily used by the class has been Matlab. I would prefer to do the
bulk of the project in python because I'm familiar with pygame (for the
visuals) but I already have a lot of AI code written in Matlab.

I'd like to be able to call Matlab code from within python. I'm not sure
this is possible. My code runs in Octave just fine. I've heard about
numerical python and scipy, but I'm not sure what tool is going to mean
the least amount of recoding for me. At the very least I need to find a
really fast package for matrix operations.

Anyone have any input on what the best tool for the job would be? I've
googled, but I figure it's best to ask experience ;)
 
R

Robert Kern

dataangel said:
I'm a student who's considering doing a project for a Machine Learning
class on pathing (bots learning to run through a maze). The language
primarily used by the class has been Matlab. I would prefer to do the
bulk of the project in python because I'm familiar with pygame (for the
visuals) but I already have a lot of AI code written in Matlab.

I'd like to be able to call Matlab code from within python. I'm not sure
this is possible. My code runs in Octave just fine.

There have been some bridges between Matlab and Python, but most of them
are old, I believe.

http://claymore.engineer.gvsu.edu/~steriana/Python/pymat.html

If you're on Windows, this may help:

http://www.geocities.com/ptmcg/python/using_matlab_from_python.html
I've heard about
numerical python and scipy, but I'm not sure what tool is going to mean
the least amount of recoding for me. At the very least I need to find a
really fast package for matrix operations.

That would be Numeric and scipy. You'll probably need Numeric anyways
for pygame. scipy has a set of functions that try to mimic Matlab
functionality with the same names, so that may help in translating the code.
Anyone have any input on what the best tool for the job would be? I've
googled, but I figure it's best to ask experience ;)

--
Robert Kern
(e-mail address removed)

"In the fields of hell where the grass grows high
Are the graves of dreams allowed to die."
-- Richard Harter
 
A

Alexander Schmolck

Robert Kern said:
There have been some bridges between Matlab and Python, but most of them are
old, I believe.

http://claymore.engineer.gvsu.edu/~steriana/Python/pymat.html

Actually, I've written a highlevel matlab-python bridge (based on bugfixed and
slightly extended version of the original pymat) which is quite up-to-date; by
and large it makes using matlab from python as easy as if matlab were just
some python library:
from mlabwrap import mlab; mlab.plot([1,2,3],'-o')
mlab.sin([4,5,6])
array([[-0.7568025 ],
[-0.95892427],
[-0.2794155 ]])

As you can see from the last example there a certain minor idiosyncrasies
stemming from unbridgable semantic differences between matlab and python
(matlab doesn't have "real" vectors, which means that Numeric vectors are
translated to Nx1 matrices), also the call to matlab of course incurs a
significant overhead compared to Numeric.sin.

All in all I it works quite well for me, though (I've been using it
productively for years now and a couple of other people have also used it) --
so I guess I should finally announce it (there were a few minor things I
wanted to add first, but since people periodically ask for something like it
on c.l.py so now would seem like a good time).

You can find it on sourceforge:

<http://mlabwrap.sf.net>

I'd appreciate feedback.

'as

p.s. never mind the project activity meter at 0% -- as you can see the latest
version was uploaded mid january this year.
 
R

Robert Kern

Alexander said:
Actually, I've written a highlevel matlab-python bridge (based on bugfixed and
slightly extended version of the original pymat) which is quite up-to-date; by
and large it makes using matlab from python as easy as if matlab were just
some python library:

Fantastic! I've added a link to the Scipy Wiki:

http://www.scipy.org/wikis/topical_software/TopicalSoftware

--
Robert Kern
(e-mail address removed)

"In the fields of hell where the grass grows high
Are the graves of dreams allowed to die."
-- Richard Harter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,997
Messages
2,570,239
Members
46,827
Latest member
DMUK_Beginner

Latest Threads

Top