Linear Discriminant Analysis transform function

1.4k views Asked by At
x = data.values
y = target.values
lda = LDA(solver='eigen', shrinkage='auto',n_components=2)
df_lda = lda.fit(x,y).transform(x)
df_lda.shape

This is the small part of the code. I am trying to reduce the dimensionality to the most discriminative directions. To my understanding the transform() function projects data to maximize class separation for my data set and should return an array of shape (n_samples, n_components)

But my df_lda is of shape (614, 1).

What am I missing here ? Or is my data not linearly separable?.

1

There are 1 answers

0
bogatron On BEST ANSWER

For the case of K distinct classes in target.values there are K-1 components in the transformed data (without further dimensionality reduction). Since you only have two classes in your data set, there is only one transformed component so you cannot get more components than that.

I suppose it might by helpful for sklearn to issue a warning when you request more than are available.