Answers.Body: <p>The short answer is yes.</p>
  <p>When you merge the test set into the train set, you try to squeeze available data till the last drop. The cons and pros of this approach have been considered in other questions in the network <a href="https://datascience.stackexchange.com/questions/33008/is-it-always-better-to-use-the-whole-dataset-to-train-the-final-model">1</a>, <a href="https://stats.stackexchange.com/questions/184095/should-final-production-ready-model-be-trained-on-complete-data-or-just-on-tra">2</a>. But if you decided to go for it, there is no point to not use the whole dataset for the scaling transformation, as the trend &quot;more data leads (generally) to better models&quot; is valid to the scaling to the same extent it's valid for the model itself.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-03-29T12:42:50.507Z
Answers.LastActivityDate: 2021-03-29T13:20:36.483Z
Answers.LastEditDate: 2021-03-29T13:20:36.483Z
Answers.UserDisplayName: Kirill Fedyanin
Body: <p>We have our training set and our test set. When we scale our data we &quot;fit&quot; the scaler transform to the training set and then we scale both the training set and test set using this scaler object. Using splitting and cross-validation techniques, one can use the training set as training and validation. Finally, reporting on the test set.</p>
  <p>Now, if I want to use a model in a real-life environment, it's common to use the entire dataset (training and test) to train our already optimized model to obtain a final ready for the production model.</p>
  <p>My question is regarding scaling. Should we fit the scaler to the entire set and then scale? Or can we simply append the scaled training set and scaled test set (both have been scaled using the training set's scaling parameters)?</p>
  <p>I am making use of <a href="https://scikit-learn.org/stable/modules/generated/sklearn.preprocessing.PowerTransformer.html" rel="nofollow noreferrer"><code>sklearn.preprocessing.PowerTransformer</code></a>. Using &quot;Yeo-Johnson's&quot; power transform and also standardizing the data.</p>
  
Tags: <neural-networks><deep-learning>
Title: Is the final model scaling done on the full training set?
UserDisplayName: nachofest
ThreadText: # Is the final model scaling done on the full training set?
  
  (Asked by: username_0 on 2021-03-28)
  
  We have our training set and our test set. When we scale our data we "fit" the scaler transform to the training set and then we scale both the training set and test set using this scaler object. Using splitting and cross-validation techniques, one can use the training set as training and validation. Finally, reporting on the test set.
  
  Now, if I want to use a model in a real-life environment, it's common to use the entire dataset (training and test) to train our already optimized model to obtain a final ready for the production model.
  
  My question is regarding scaling. Should we fit the scaler to the entire set and then scale? Or can we simply append the scaled training set and scaled test set (both have been scaled using the training set's scaling parameters)?
  
  I am making use of [`sklearn.preprocessing.PowerTransformer`](https://scikit-learn.org/stable/modules/generated/sklearn.preprocessing.PowerTransformer.html). Using "Yeo-Johnson's" power transform and also standardizing the data.
  
  **Tags:** neural-networks, deep-learning
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2021-03-29. Score: 0 | Accepted answer
  
  The short answer is yes.
  
  When you merge the test set into the train set, you try to squeeze available data till the last drop. The cons and pros of this approach have been considered in other questions in the network [1](https://datascience.stackexchange.com/questions/33008/is-it-always-better-to-use-the-whole-dataset-to-train-the-final-model), [2](https://stats.stackexchange.com/questions/184095/should-final-production-ready-model-be-trained-on-complete-data-or-just-on-tra). But if you decided to go for it, there is no point to not use the whole dataset for the scaling transformation, as the trend "more data leads (generally) to better models" is valid to the scaling to the same extent it's valid for the model itself.
  
  
  ---
  
  