To do PCA, we have to compute the covariance matrix from our input data and then eigen decomposition is performed in that covariance matrix.
And to get the covariance matrix, we have to calculate the mean and then substract it with our data (data in matrix). But the problem is that Im going to perform PCA for classification.
And Im confused about how to compute the mean (it must be mean computed in row (consider for the class) / column (consider for the features))?
As in my case, here is the format of my *Feature Matrix*:
Class1: feat1 feat2 feat3...
Class2: feat1 feat2 feat3...
Class3: feat1 feat2 feat3...
Class4: feat1 feat2 feat3...
Class5: feat1 feat2 feat3...
.
.
.
ClassN: feat1 feat2 feat3...
What I have done is
so I have ( *Mean Matrix* )
Mean_Class1
Mean_Class2
Mean_Class3
Mean_Class4
Mean_Class5
.
.
.
Mean_ClassN
And then I Substract the data in my *Feature Matrix* with those mean. So it becomes (*Substract Matrix*):
Class1: feat1-Mean_Class1 feat2-Mean_Class2 feat3-Mean_Class3...
Class2: feat1-Mean_Class1 feat2-Mean_Class2 feat3-Mean_Class3...
Class3: feat1-Mean_Class1 feat2-Mean_Class2 feat3-Mean_Class3...
Class4: feat1-Mean_Class1 feat2-Mean_Class2 feat3-Mean_Class3...
Class5: feat1-Mean_Class1 feat2-Mean_Class2 feat3-Mean_Class3...
.
.
.
ClassN: feat1-Mean_Class1 feat2-Mean_Class2 feat3-Mean_Class3...
Next is the *Covariance Matrix*:
(Substract Matrix)*(Substract Matrix)^T
The Principal components are extracted from this Covariance Matrix by using eigs [Vectors,Values] = eigs(CovarianceMatrix);
And for dimensionality reduction, I have to project those data after substract with its mean onto the extracted eigen vectors.
And then to project it:
Substract Matrix * Vectors
1. Are those right? Or there are some mistakes concept?
2. Or I have to compute the mean for each column (consider the Features number)?
3. And for projecting onto the new space, Is that right that I have to substract the data in the matrix with its mean (mean calculated for each row)?
Sorry If this is kind of stupid question, but I really need to confirm the true concept..
Hope someone will kindly answer my this question