I'm trying to do some cluster analysis and running into a small problem. The cluster package which is included in scipy only does k-means style clustering, and I need to do hierarchical clustering as well. So I downloaded Pycluster which has that ability. However, Pycluster uses Numeric, which I no longer have since scipy was upgraded to use numpy instead. Does anyone have any experience with updating packages to use numpy instead of Numeric? I tried replacing the "from Numeric import *" line in Pycluster with "from numpy import *" but this creates a program fault which crashes Python. -- R. Padraic Springuel Teaching Assistant Department of Physics and Astronomy University of Maine Bennett 214 Office Hours: By Appointment only during the Summer
R. Padraic Springuel wrote:
I'm trying to do some cluster analysis and running into a small problem. The cluster package which is included in scipy only does k-means style clustering, and I need to do hierarchical clustering as well. So I downloaded Pycluster which has that ability. However, Pycluster uses Numeric, which I no longer have since scipy was upgraded to use numpy instead. Does anyone have any experience with updating packages to use numpy instead of Numeric? I tried replacing the "from Numeric import *" line in Pycluster with "from numpy import *" but this creates a program fault which crashes Python.
Are you using a binary version of PyCluster? This will most certainly not work. You will at least have to alter the extension module generated by PyCluster. It looks like PyCluster uses PyFort for the interface. Ideally, this should be converted to use f2py, but if the pyfort just generated an extension module, then this extension module should compile with NumPy just fine as long as the include files are changed to be #include numpy/arrayobject.h There may be some additional corrections that need to be made to the python side. Most of these can be done with the convertcode script. There is some talk about creating a fully backward compatible library so that you can replace Numeric with numpy.oldnumeric and have code work. I'm not sure if we can get 100% of the way there, but maybe. You will still need to re-compile extension modules, though. -Travis
You can install Numeric too (so having numpy/scipy living together with Numeric): PyCluster will use Numeric internally and you'll use numpy/scipy in your code. Passing data from numpy/scipy to Pycluster/Numeric and results from Pycluster/Numeric to numpy/scipy is flawless: just passing a numpy array to Pycluster is ok and constructing a numpy array from Pycluster's results works fine. I'm using Pycluster in this way. It's not the best solution but it is fast. I talked to Michiel de Hoon (Pycluster's author) one month ago and he said that he will not port Pycluster to numpy in the short term. Cheers, Emanuele R. Padraic Springuel wrote:
I'm trying to do some cluster analysis and running into a small problem. The cluster package which is included in scipy only does k-means style clustering, and I need to do hierarchical clustering as well. So I downloaded Pycluster which has that ability. However, Pycluster uses Numeric, which I no longer have since scipy was upgraded to use numpy instead. Does anyone have any experience with updating packages to use numpy instead of Numeric? I tried replacing the "from Numeric import *" line in Pycluster with "from numpy import *" but this creates a program fault which crashes Python.
participants (3)
-
Emanuele Olivetti -
R. Padraic Springuel -
Travis Oliphant