computing z-scores for 2D matrices in scipy/numpy in Python

Posted by user248237 on Stack Overflow See other posts from Stack Overflow or by user248237
Published on 2010-06-06T17:29:56Z Indexed on 2010/06/06 17:32 UTC
Read the original article Hit count: 392

How can I compute the z-score for matrices in Python?

Suppose I have the array:

a = array([[   1,    2,    3],
           [  30,   35,   36],
           [2000, 6000, 8000]])

and I want to compute the z-score for each row. The solution I came up with is:

array([zs(item) for item in a])

where zs is in scipy.stats.stats. Is there a better built-in vectorized way to do this?

Also, is it always good to z-score numbers before using hierarchical clustering with euclidean or seuclidean distance? Can anyone discuss the relative advantages/disadvantages?

thanks.

© Stack Overflow or respective owner

Related posts about python

Related posts about numpy