title: Problems with using sklearm.preprocessing.PowerTransformer() before splitting data using train_test_split
body: <p>Since my data are not normally distributed so I decided to use PowerTransformer on X, y before splitting them to X_train, X_test, y_train, y_test. Is it okay if I do this or I should perform transformation later. Here is my code:</p>
  <pre><code>X = df[['Aces', 'TotalPointsWon', 'ServiceGamesWon', 'TotalServicePointsWon']]
  y = df[['Winnings']]
  
  transformer_X = PowerTransformer()
  X_log = transformer_X.fit_transform(X)
  
  transformer_y = PowerTransformer()
  y_log = transformer_y.fit_transform(y)
  
  X_train, X_test, y_train, y_test = train_test_split(X_log, y_log, train_size=0.8)
  
  scaler = StandardScaler()
  scaler.fit_transform(X_train)
  scaler.transform(X_test)
  
  model = LinearRegression()
  model.fit(X_train, y_train)
  </code></pre>
  <p><a href="https://i.stack.imgur.com/Z6dER.png" rel="nofollow noreferrer">Residuals Analyses Graph</a></p>
  <p>Thanks for helping out.</p>