title: Using PCA on linear regression
body: <p>I want to use principal component analysis to reduce some noise before applying linear regression.</p>
  
  <p>I have 1000 samples and 200 features </p>
  
  <pre><code>import numpy as np
  from sklearn.linear_model import LinearRegression
  from sklearn.decomposition import PCA
  
  X = np.random.rand(1000,200)
  y = np.random.rand(1000,1)
  </code></pre>
  
  <p>With this data I can train my model: </p>
  
  <pre><code>model.fit(X,y)
  </code></pre>
  
  <p>But if I try the same after applying PCA</p>
  
  <pre><code>pca = PCA(n_components=8)
  pca.fit(X)
  PCA(copy=True, iterated_power='auto', n_components=3, random_state=None,
    svd_solver='auto', tol=0.0, whiten=False)
  principal_components =  pca.components_
  
  model.fit(principal_components,y)
  </code></pre>
  
  <p>I get this error:</p>
  
  <pre><code>ValueError: Found input variables with inconsistent numbers of samples: [8, 1000]
  </code></pre>