title: Are the k-fold cross-validation scores from scikit-learn's `cross_val_score` and `GridsearchCV` biased if we include transformers in the pipeline?
body: <p>Data pre-processers such as StandardScaler should be used to fit_transform the train set and only transform (not fit) the test set. I expect the same fit/transform process applies to cross-validation for tuning the model. However, I found <code>cross_val_score</code> and <code>GridSearchCV</code> fit_transform the entire train set with the preprocessor (rather than fit_transform the inner_train set, and transform the inner_validation set). I believe this artificially removes the variance from the inner_validation set which makes the cv score (the metric used to select the best model by GridSearch) biased. Is this a concern or did I actually miss anything?</p>
  
  <p>To demonstrate the above issue, I tried the following three simple test cases with the Breast Cancer Wisconsin (Diagnostic) Data Set from Kaggle. </p>
  
  <ol>
  <li>I intentionally fit and transform the entire X with <code>StandardScaler()</code></li>
  </ol>
  
  <pre><code>X_sc = StandardScaler().fit_transform(X)
  lr = LogisticRegression(penalty='l2', random_state=42)
  cross_val_score(lr, X_sc, y, cv=5)
  </code></pre>
  
  <ol start="2">
  <li>I include SC and LR in the <code>Pipeline</code> and run <code>cross_val_score</code></li>
  </ol>
  
  <pre><code>pipe = Pipeline([
      ('sc', StandardScaler()),
      ('lr', LogisticRegression(penalty='l2', random_state=42))
  ])
  cross_val_score(pipe, X, y, cv=5)
  </code></pre>
  
  <ol start="3">
  <li>Same as 2 but with <code>GridSearchCV</code></li>
  </ol>
  
  <pre><code>pipe = Pipeline([
      ('sc', StandardScaler()),
      ('lr', LogisticRegression(random_state=42))
  ])
  params = {
      'lr__penalty': ['l2']
  }
  gs=GridSearchCV(pipe,
  param_grid=params, cv=5).fit(X, y)
  gs.cv_results_
  </code></pre>
  
  <p>They all produce the same validation scores.
  [0.9826087 , 0.97391304, 0.97345133, 0.97345133, 0.99115044]</p>