title: Normalize PCA with scikit-learn when data is split
body: <p>I have a followup question on: <a href="https://stackoverflow.com/questions/25475465/how-to-normalize-with-pca-and-scikit-learn">How to normalize with PCA and scikit-learn</a>.</p>
  
  <p>I'm creating an emotion detection system and what I do now is:</p>
  
  <ol>
  <li>Split data over all emotion (distributing data over multiple subsets).</li>
  <li>Add all data together (the multiple subsets into 1 set)</li>
  <li>Get PCA parameters of combined data (self.pca = RandomizedPCA(n_components=self.n_components, whiten=True).fit(self.data))</li>
  <li>Per emotion (per subset), apply PCA to data of that emotion (subset).</li>
  </ol>
  
  <p>I should do the normalization at: step 2) Normalize all combined data, and step 4) normalize the subsets.</p>
  
  <h2>Edit</h2>
  
  <p>I was wondering if the normalization over all data and the normalization over subset is the same. Now when I tried to simplify my example on suggestion of @BartoszKP I figured out that how I understood the normalization worked, was wrong. The normalization in both cases work in the same way, so this is a valid way to do it, right? (see code)</p>
  
  <pre><code>from sklearn.preprocessing import normalize
  from sklearn.decomposition import RandomizedPCA
  import numpy as np
  
  data_1 = np.array(([52, 254], [4, 128]), dtype='f')
  data_2 = np.array(([39, 213], [123, 7]), dtype='f')
  data_combined = np.vstack((data_1, data_2))
  #print(data_combined)
  """
  Output
  [[  52.  254.]
   [   4.  128.]
   [  39.  213.]
   [ 123.    7.]]
  """
  #Normalize all data
  data_norm = normalize(data_combined)
  print(data_norm)
  """
  [[ 0.20056452  0.97968054]
   [ 0.03123475  0.99951208]
   [ 0.18010448  0.98364753]
   [ 0.99838448  0.05681863]]
  """
  
  pca = RandomizedPCA(n_components=20, whiten=True)
  pca.fit(data_norm)
  
  #Normalize subset of data
  data_1_norm = normalize(data_1)
  print(data_1_norm)
  """
  [[ 0.20056452  0.97968054]
   [ 0.03123475  0.99951208]]
  """
  pca.transform(data_1_norm)
  </code></pre>