krrepo / scipy-cluster

Automatically exported from code.google.com/p/scipy-cluster
Other
0 stars 0 forks source link

TypeError when running pdist #29

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
I'm running hcluster v0.2.0 under linux (CentOS5) with python 2.4.3 and
numpy version: 1.0.1.

I have 6 observations that each comprise ~45000 datapoint (i.e., a 6x45000
numpy array). I want to compute the euclidean distances between the 6
observations. When I try:

dists=pdist(data, 'seuclidean')

I encounter the following error:

File "...lib/python2.4/site-packages/hcluster/distance.py", line 1151, in pdist
VV = np.var(X, axis=0, ddof=1)
TypeError: var() got an unexpected keyword argument 'ddof'

Any ideas?

Original issue reported on code.google.com by nickschu...@gmail.com on 5 Jan 2010 at 5:21

GoogleCodeExporter commented 8 years ago
The help section of the numpy.var function says:

---------------------------------
Help on function var in module numpy.core.fromnumeric:

var(a, axis=None, dtype=None, out=None)
    var(sample, axis=None, dtype=None)
    Return the variance, a measure of the spread of a distribution.

    The variance is the average of the squared deviations from the mean,
    i.e. var = mean((x - x.mean())**2).

    See also: std
---------------------------------------

So it looks like 'ddof' is not a valid argument for this - do I have the wrong
version of numpy? 

Original comment by nickschu...@gmail.com on 6 Jan 2010 at 9:37

GoogleCodeExporter commented 8 years ago
Hi Nick,

You might have the wrong version of NumPy. The ddof parameter is the number of
degrees of freedom. It's been available with every version of NumPy I've used 
over
the past two years. Red Hat Enterprise is very slow with updating NumPy and may 
still
distribute 1.0.3. What version of linux are you using?

Try the following within ipython

  import numpy
  print numpy.version.version

When I try it on my machine, I get version 1.2.1.

Thanks,

Damian Eads

Original comment by damian.e...@gmail.com on 8 Jan 2010 at 2:18

GoogleCodeExporter commented 8 years ago
As I said in my original comment, I have version 1.0.1(!) - so it looks like 
thats
the problem! I'll install the latest numpy and see if that fixes things...

Original comment by nickschu...@gmail.com on 8 Jan 2010 at 9:16

GoogleCodeExporter commented 8 years ago
Sorry, my fault, I did read your original posting carefully enough. ;) CentOS
probably distributes a very old version. Compiling NumPy should not be too 
painful.
Compiling SciPy on the other hand will be nontrivial.

Original comment by damian.e...@gmail.com on 8 Jan 2010 at 7:27

GoogleCodeExporter commented 8 years ago
New version of numpy seems to have solved the problem. :D

Original comment by nickschu...@gmail.com on 14 Jan 2010 at 10:26

GoogleCodeExporter commented 8 years ago
Excellent!

Original comment by damian.e...@gmail.com on 16 Jan 2010 at 3:12