Re: [Numpy-discussion] SParse feature vector generation

2012-01-10 Thread Samuel John
I would just use a lookup dict: names = [ "uc_berkeley", "stanford", "uiuc", "google", "intel", "texas_instruments", "bool"] lookup = dict( zip( range(len(names)), names ) ) Now, given you have n entries: S = numpy.zeros( (n, len(names)) ,dtype=numpy.int32) for k in ["uc_berkeley", "google",

[Numpy-discussion] SParse feature vector generation

2012-01-03 Thread Dhruvkaran Mehta
Hi numpy users, *Is there a convenient way in numpy to go from "string" features like:* "uc_berkeley", "google", 1 "stanford", "intel", 1 . . . "uiuc", "texas_instruments", 0 *to a numpy matrix like:* "uc_berkeley", "stanford", ..., "uiuc", "google", "intel", "texas_instruments", "bool"