title: How to normalize the Train and Test data using MinMaxScaler sklearn
body: <p>So, I have this doubt and have been looking for answers. So the question is when I use,</p>
  
  <pre><code>from sklearn import preprocessing
  min_max_scaler = preprocessing.MinMaxScaler()
  
  df = pd.DataFrame({'A':[1,2,3,7,9,15,16,1,5,6,2,4,8,9],'B':[15,12,10,11,8,14,17,20,4,12,4,5,17,19],'C':['Y','Y','Y','Y','N','N','N','Y','N','Y','N','N','Y','Y']})
  
  df[['A','B']] = min_max_scaler.fit_transform(df[['A','B']])
  df['C'] = df['C'].apply(lambda x: 0 if x.strip()=='N' else 1)
  </code></pre>
  
  <p>After which I will train and test the model (<code>A</code>,<code>B</code> as features, <code>C</code> as Label) and get some accuracy score. Now my doubt is, what happens when I have to predict the label for new set of data. Say,</p>
  
  <pre><code>df = pd.DataFrame({'A':[25,67,24,76,23],'B':[2,54,22,75,19]})
  </code></pre>
  
  <p>Because when I normalize the column the values of <code>A</code> and <code>B</code> will be changed according to the new data, not the data which the model will be trained on.
  So, now my data after the data preparation step that is as below, will be.</p>
  
  <pre><code>data[['A','B']] = min_max_scaler.fit_transform(data[['A','B']])
  </code></pre>
  
  <p>Values of <code>A</code> and <code>B</code> will change with respect to the <code>Max</code> and <code>Min</code> value of <code>df[['A','B']]</code>. The data prep of <code>df[['A','B']]</code> is with respect to <code>Min Max</code> of <code>df[['A','B']]</code>.</p>
  
  <p>How can the data preparation be valid with respect to different numbers relate? I don't understand how the prediction will be correct here. </p>