0

I have a trouble with supervised classification method I am using for my data.

Let's think we are training our algorithm with a data (N=70) after reducing the dimensions from 100 to 2 by using LDA dimensionality reduction method.

Now, we would like to predict the class of the 71st sample, whose class is completely unknown to us. However, it has 100 features still; so we have to reduce its dimensions.

That seems easy in the first look: I can use the transform characteristics of the first reduction. For example, in python:

clf.fit(X,Y)
lda = LinearDiscriminantAnalysis(n_components=2)
flda = lda.fit(X, Y)
X_lda = flda.transform(X)

I had stored the fitting properties of training data. X_p is my single sample. So when I use 'flda' again for transformation, same fitting information is used:

X_p = flda.transform(X_p.reshape(1, -1))

However, it doesn't predict properly! To test, I used my first N=70 data. Extract one of them (so now, it is N=69). I used 70th data as test sample. And it didn't predict properly again.

When I compared my previous data (N=70) and the new one (N=69), I saw that every single number changed! If I am not missing something (I hope I am missing and you can tell me what I am missing) LDA dimensionality reduction is not applicable for real machine learning applications, because only one data could change everything.

As a note, the plot of the reduced data doesn't change, despite all numbers significanly change (which means the relative locations of points do not change).

Do you know how LDA dimensionality reduction is used in real machine learning applications? What must I do, to test one sample in the following order:

  • Reduce dimensions to 2 for training data
  • Reduce dimensions to 2 for test data
  • Predict!

without using the same tranformation charactheristics?

Zamanusta
  • 25
  • 6
  • 1
    use more components and try again. this should improve the performance. FYI LDA is one of the best tools in ML. Additionally, you can use Cross validation using X,Y to first see how LDA performs on them. Then try to predict a new sample (the 71st). Finally, N=70 is small sample size in case that your data are difficult to be predicted. – seralouk Oct 13 '18 at 20:43
  • I tried it with n_components = 4 and I undestood that I know this parameter wrong. LDA every time reduces the data into two features. I would like to show you something. The first group is the LDA transform result of N=70 data (first three elements). I extracted the 31st data and the N=69 data changed as the second group. One element changes everything in LDA! N=70 -> `[ 4.38171406e-01 4.63708770e-01] [ 2.36359003 -3.91543203e-01] [ 2.99460274 -2.55816710e+00] ...` N=69 -> `[ 0.48955035 0.43598169] [ 2.2251005 -0.24454829] [ 2.94633758 -2.52994134] ...` – Zamanusta Oct 13 '18 at 21:32
  • can you add the full code and the data? – seralouk Oct 13 '18 at 22:30
  • I can't share data according to the rules of the project :/ Actually, I think I found the problem. I have 1600 features and LDA is not working well when the amount of features are high. – Zamanusta Oct 15 '18 at 12:43

0 Answers0