Quantcast
Channel: OpenCV Q&A Forum - Latest question feed
Viewing all articles
Browse latest Browse all 19555

Why does LDA reduction give only one dimension for two classes?

$
0
0
Hi, I'm trying to reduce data from two classes with the Linear Discriminant Analysis algorithm ([LDA opencv documentation here](http://docs.opencv.org/3.0.0/db/d59/classcv_1_1LDA.html)). Here is a short example of what I'm trying to accomplish: LDA lda(num_components); lda.compute(someData, classesLabels); //Computes LDA algorithm to find the best projection Mat reductedData = lda.project(someData); //Reduces input data Let's say I've 100 dimensions per sample as input and I want to get 50 after reduction. If I'm correctly understanding the documentation ([here](http://docs.opencv.org/3.0.0/db/d59/classcv_1_1LDA.html#a6d654ebfab272bf734a6ffa35b3ce908)), num_components should be the number of kept dimensions. However I'm obtaining only one dimension regardless of the number I give to the LDA constructor. I looked at the LDA source code ([here](https://github.com/Itseez/opencv/blob/master/modules/core/src/lda.cpp#L984)) which explains this behaviour : ... // number of unique labels int C = (int)num2label.size(); ... ... // clip number of components to be a valid number if ((_num_components <= 0) || (_num_components > (C - 1))) { _num_components = (C - 1); } ... _eigenvalues = Mat(_eigenvalues, Range::all(), Range(0, _num_components)); _eigenvectors = Mat(_eigenvectors, Range::all(), Range(0, _num_components)); *Here are my questions:* - The behaviour in the documentation and the code seem to be different, is it normal ? If so, could someone explain why the number of output dimensions should be linked to the number of classes ? - How should I proceed to have more than one dimension with two classes ?

Viewing all articles
Browse latest Browse all 19555

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>