>>> import numpy as np
>>> from sklearn.lda import LDA
>>> from sklearn.utils.testing import assert_equal
>>>
>>> state = np.random.RandomState(0)
>>> X = state.normal(loc=0, scale=100, size=(40, 20))
>>> y = state.randint(0, 3, size=(40, 1))
>>>
>>> # Train the LDA classifier. Use the eigen solver
>>> lda_eigen = LDA(solver='eigen', n_components=5)
>>> lda_eigen.fit(X, y)
>>> assert_equal(lda_eigen.explained_variance_ratio_.shape, (5,))
AssertionError: Tuples differ: (20,) != (5,)
First differing element 0:
20
5
- (20,)
+ (5,)
Looks like we fix either the docs or the code. Which one?
The docs say that LDA.explained_variance_ratio_ should have only
n_components_. But it doesn't.It looks like this bug only exists when we use the
eigensolver, not thesvdsolver.Looks like we fix either the docs or the code. Which one?
Pinging @JPFrancoia.
Addresses an issue in #6031.