title: n_components cannot be larger than min(n_features, n_classes - 1). while performing LDA
body: <pre><code>from sklearn.preprocessing import LabelEncoder
  class_le = LabelEncoder()
  y = class_le.fit_transform(data['10'].values)
  
  from sklearn.preprocessing import StandardScaler
  stdsc = StandardScaler()
  X_train_std = stdsc.fit_transform(data.iloc[:,range(int(0),int(10))].values) 
  
  from sklearn.discriminant_analysis import LinearDiscriminantAnalysis
  lda = LinearDiscriminantAnalysis(n_components=2)
  X_train_lda = lda.fit_transform(X_train_std, y)
  </code></pre>
  <p>this is the error even if am changing the dataset it is showing same error. My dataset contains 9 attributes+class. If i give n_components=1 it is taking if i give any other number it is showing error.</p>
  <pre><code>ValueError                                Traceback (most recent call last)
  &lt;ipython-input-8-b53ad0e7c804&gt; in &lt;module&gt;()
        1 from sklearn.discriminant_analysis import LinearDiscriminantAnalysis
        2 lda = LinearDiscriminantAnalysis(n_components=2)
  ----&gt; 3 X_train_lda = lda.fit_transform(X_train_std, y)
  
  1 frames
  /usr/local/lib/python3.7/dist-packages/sklearn/discriminant_analysis.py in fit(self, X, y)
      575             if self.n_components &gt; max_components:
      576                 raise ValueError(
  --&gt; 577                     &quot;n_components cannot be larger than min(n_features, n_classes - 1&quot;
      578                 )
      579             self._max_components = self.n_components
  
  ValueError: n_components cannot be larger than min(n_features, n_classes - 1).
  </code></pre>