Showing posts with label python. Show all posts
Showing posts with label python. Show all posts

Thursday, April 5, 2012

Copy one sparse matrix into another in Python


Copying Xf into features. In this case, Xf is a scipy.sparse.csr_matrix and features is a dok_matrix.

        nz_indices = Xf.nonzero()
        for ix, jx in zip(nz_indices[0], nz_indices[1]):
            features[ix, jx] = Xf[ix, jx]

Notes: 

1. When I checked, the assignment of a 0 to an element of a dok_matrix resulted in a crash. So 0 assignments have to be avoided. 

Thursday, March 26, 2009

Python

I am trying to run matplotlib but seems it is not installed on my windows (ActivePython 2.6) package. Therefore I was looking for a good way to install it. Now, it is a part of several scientific libraries and these libraries have different installers.

One good way to install is using easy_install, but it looks not possible for python 2.6. Finally I gave up on easy_install. I downloaded the matplotlib library (for python 2.5 as there is none corresponding to 2.6).

Finally I concluded that there is little support for python 2.6 and I uninstalled the 2.6 version and installed the 2.5 version.