By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,387 Members | 1,751 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,387 IT Pros & Developers. It's quick & easy.

Python, Matlab and AI question

P: n/a
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 ;)
Jul 18 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
dataangel wrote:
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/~s...hon/pymat.html

If you're on Windows, this may help:

http://www.geocities.com/ptmcg/pytho...om_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
rk***@ucsd.edu

"In the fields of hell where the grass grows high
Are the graves of dreams allowed to die."
-- Richard Harter
Jul 18 '05 #2

P: n/a
Robert Kern <rk***@ucsd.edu> writes:
dataangel wrote:
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/~s...hon/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') <imagine plot here> 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.
Jul 18 '05 #3

P: n/a
Alexander Schmolck wrote:
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_s...opicalSoftware

--
Robert Kern
rk***@ucsd.edu

"In the fields of hell where the grass grows high
Are the graves of dreams allowed to die."
-- Richard Harter
Jul 18 '05 #4

P: n/a
Robert Kern <rk***@ucsd.edu> writes:
Alexander Schmolck wrote:
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_s...opicalSoftware


Thanks -- I've now also posted announcements to the relevant forums, so I
guess I'll find out pretty soon if others deem it to be useful (working :).

'as
Jul 18 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.