1

I have been trying to do some dimensionality reduction using PCA. I currently have an image of size (100, 100) and I am using a filterbank of 140 Gabor filters where each filter gives me a response which is again an image of (100, 100). Now, I wanted to do feature selection where I only wanted to select non-redundant features and I read that PCA might be a good way to do.

So I proceeded to create a data matrix which has 10000 rows and 140 columns. So, each row contains the various responses of the Gabor filters for that filterbank. Now, as I understand it I can do a decomposition of this matrix using PCA as

from sklearn.decomposition import PCA

pca = pca(n_components = 3)
pca.fit(Q) # Q is my 10000 X 140 matrix

However, now I am confused as to how I can figure out which of these 140 feature vectors to keep from here. I am guessing it should give me 3 of these 140 vectors (corresponding to the Gabor filters which contain the most information about the image) but I have no idea how to proceed from here.

Bono
  • 4,757
  • 6
  • 48
  • 77
Luca
  • 10,458
  • 24
  • 107
  • 234
  • I thought I could use the principal components now as the features rather than the original gabor features. Otherwise, i could also use the top x number of features in terms of their absolute coefficient values. – Luca Nov 05 '14 at 13:26
  • Wouldn't you want to be doing this on several images, i.e. a matrix of `(n_images, 140 * 10000)`? Or image patches? What is the goal? – eickenberg Nov 05 '14 at 17:34
  • Also [this](http://stackoverflow.com/questions/23294616/how-to-use-scikit-learn-pca-for-features-reduction-and-know-which-features-are-d/) may or may not be helpful. If you want a combination of components, OK. If you want to select specific Gabors, univariate feature selection is better. – eickenberg Nov 05 '14 at 17:36

1 Answers1

4

PCA will give you a linear combination of features, not a selection of features. It will give you the linear combination that is the best for reconstruction in the L2 sense, aka the one that captures the most variance.

What is you goal? If you do this on one image, any kind of selection will give you features that will discriminate best some parts of an image against other parts of the same image.

Also: Garbor Filters are a sparse basis for natural images. I would not expect anything interesting to happen unless you have very specific images.

Andreas Mueller
  • 27,470
  • 8
  • 62
  • 74
  • 1
    Thanks for the answer! My goal was to reduce the number of features really and I thought with PCA I can look at the features that covers the maximum variance in data and hence are more informative in that sense i.e. I can discard some features or set their weight to zero and still get most of the interesting information about the image structure. Did I not understand that correctly? I have seen some papers where they do PCA on these Gabor filters responses and I was wondering to try this. – Luca Nov 05 '14 at 19:07
  • 2
    Maybe my question was unclear. You want to reduce the number of feature to do what. That is probably not your goal in itself, right? And yes, I think you misunderstood what PCA does. It finds directions in the space spanned by all features that are covering the most variance. – Andreas Mueller Nov 05 '14 at 21:34
  • 1
    It is basically for computational reasons. At the moment, for each of the Gabor filters, I get an output of 100x100 and I have 140 of them. My feeling was that some of them might be providing redundant information and I can select somehow the n most independent features that explain the data or most of it.. – Luca Nov 05 '14 at 21:56
  • 3
    In that case people often do "pooling" over neighboring locations in the image, but keep all 140 of them. You can look into the [classical HMAX model](http://www.nature.com/neuro/journal/v2/n11/full/nn1199_1019.html) or some [more recent work from the neural nets community](http://web.eecs.umich.edu/~honglak/aistats11-AnalysisSingleLayerUnsupervisedFeatureLearning.pdf). The idea is to compute a maximum or mean for each potion of the image for each gabor filter. – Andreas Mueller Nov 05 '14 at 23:28
  • Thanks for that Andreas. I will try and summarise it that way and see what I get :-) – Luca Nov 05 '14 at 23:52