title: How can I correctly use Pipleline with MinMaxScaler + NMF to predict data?
body: <p>This is a very small sklearn snipplet:</p>
  
  <pre><code>logistic = linear_model.LogisticRegression()
  
  pipe = Pipeline(steps=[
      ('scaler_2', MinMaxScaler()),
      ('pca',  decomposition.NMF(6)),     
      ('logistic', logistic),
  ])
  
  from sklearn.cross_validation import train_test_split   
  
  Xtrain, Xtest, ytrain, ytest = train_test_split(X, y, test_size=0.2)
  
  pipe.fit(Xtrain, ytrain)    
  ypred = pipe.predict(Xtest)
  </code></pre>
  
  <p>I will get this error:</p>
  
  <pre><code>    raise ValueError("Negative values in data passed to %s" % whom)
  ValueError: Negative values in data passed to NMF (input X)
  </code></pre>
  
  <p>According to this question:
  <a href="https://stackoverflow.com/questions/30473602/scaling-test-data-to-0-and-1-using-minmaxscaler">Scaling test data to 0 and 1 using MinMaxScaler</a></p>
  
  <p>I know this is because </p>
  
  <blockquote>
    <p>This is due to the fact that the lowest value in my test data was
    lower than the train data, of which the min max scaler was fit</p>
  </blockquote>
  
  <p>But I am wondering, is this a bug? 
  MinMaxScaler (all scalers) seems should be applied before I do the prediction, it should not depends on previous fitted training data, am I right?</p>
  
  <p>Or how could I correctly use preprocessing scalers with Pipeline?</p>
  
  <p>Thanks.</p>