Estou treinando um classificador LDA de várias classes com 8 classes de dados.
Durante a execução do treinamento, recebo um aviso de: "As variáveis são colineares "
Estou recebendo uma precisão de treinamento de mais de 90% .
Estou usando a biblioteca scikits-learn no Python para treinar e testar os dados de várias classes.
Também recebo uma precisão decente nos testes (cerca de 85% -95% ).
Não entendo o significado do erro / aviso. Por favor, me ajude.
As I seem to think gui11aume has given you a great answer, I want to give an example from a slightly different angle that might be illuminating. Consider that a covariate in your discriminant function looks as follows:
Suppose the best LDA has the following linear boundary:
Then we can substitute5X2+3X3−X4 for X1 n the LDA boundary equation, so:
or
These two boundaries are identical but the first one has coefficients1,2,1,−2 for X1 , X2 , X3 , and X4 respectively, while the other has coefficients 0,7,3,−1 .
So the coefficient are quite different but the two equations give the same boundary and identical prediction rule. If one form is good the other is also. But now you can see why gui11ame says the coefficients are uninterpretable.
There are several other ways to express this boundary as well by substituting forX2 to give it the 0 coefficient and the same could be done for X3 or X4 . But in practice the collinearity is approximate. This makes things worse because the noise allows for a unique answer. Very slight perturbations of the data will cause the coefficients to change drastically. But for prediction you are okay because each equation defines almost the same boundary and so LDA will result in nearly identical predictions.
fonte
While the answer that was marked here is correct, I think you were looking for a different explanation to find out what happened in your code. I had the exact same issue running through a model.
Here's whats going on: You're training your model with the predicted variable as part of your data set. Here's an example of what was occurring to me without even noticing it:
In this code, I want to predict the value of 'COL3'... but, if you look at train_X, I'm telling it to retrieve every column except the last one, so its inputting COL1 COL2 and COL3, not COL4, and trying to predict COL3 which is part of train_X.
I corrected this by just moving the columns, manually moved COL3 in Excel to be the last column in my data set (now taking place of COL4), and then:
If you don't want to move it in Excel, and want to just do it by code then:
Note now how I declared train_X, to include all columns except COL3, which is part of train_Y.
I hope that helps.
fonte