Partition training data by class in NumPy

Viewed 1060

I have a 50000 x 784 data matrix (50000 samples and 784 features) and the corresponding 50000 x 1 class vector (classes are integers 0-9). I'm looking for an efficient way to group the data matrix into 10 data matrices and class vectors that each have only the data for a particular class 0-9.

I can't seem to find an elegant way to do this, aside from just looping through the data matrix and constructing the 10 other matrices that way.

Does anyone know if there is a clean way to do this with something in scipy, numpy, or sklearn?

3 Answers
Related