title: Is there a way to compute the explained variance of PCA on a test set?
body: <p>I want to see how well PCA worked with my data. </p>
  
  <p>I applied PCA on a training set and used the returned pca object to transform on a test set. pca object has a variable <code>pca.explained_variance_ratio_</code> which tells me the percentage of variance explained by each of the selected components for the training set. After applying the pca transform, I want to see how well this worked on the test set. I tried <code>inverse_transform()</code> that returned what the original values would look like but I have no way to compare how it worked on the train set vs test set. </p>
  
  <pre><code>pca = PCA(0.99)
  pca.fit(train_df)  
  tranformed_test = pca.transform(test_df)
  inverse_test = pca.inverse_transform(tranformed_test)
  npt.assert_almost_equal(test_arr, inverse_test, decimal=2)
  </code></pre>
  
  <p>This returns:</p>
  
  <blockquote>
    <p>Arrays are not almost equal to 2 decimals</p>
  </blockquote>
  
  <p>Is there something like <code>pca.explained_variance_ratio_</code> after <code>transform()</code>?</p>