title: Sklearn Pipeline : pass a parameter to a custom Transformer?
body: <p>I have a custom Transformer in my <code>sklearn</code> Pipeline and I wonder how to pass a parameter to my Transformer :</p>
  
  <p>In the code below, you can see that I use a dictionary "weight" in my Transformer. I wish to not define this dictionary inside my Transformer but instead to pass it from the Pipeline, so that I can include this dictionary in a grid search . Is it possible to pass the dictionary as a parameter to my Transformer ?</p>
  
  <pre><code># My custom Transformer
    class TextExtractor(BaseEstimator, TransformerMixin):
          """Concat the 'title', 'body' and 'code' from the results of 
          Stackoverflow query
          Keys are 'title', 'body' and 'code'.
          """
          def fit(self, x, y=None):
              return self
  
          def transform(self, x):
              # here is the parameter  I want to pass to my transformer
              weight ={'title' : 10, 'body': 1, 'code' : 1}
              x['text'] = weight['title']*x['Title'] +  
              weight['body']*x['Body'] +  
              weight['code']*x['Code']
  
              return x['text']
  
  param_grid = {
      'min_df' : [10],
      'max_df' : [0.01],
      'max_features': [200],
      'clf' : [sgd]
      # here is the parameter  I want to pass to my transformer
      'weigth' : [{'title' : 10, 'body': 1, 'code' : 1}, {'title' : 1, 'body': 
       1, 'code' : 1}]
  
  }
  
  for g in ParameterGrid(param_grid) :   
  
      classifier_pipe = Pipeline(
  
      steps=[    ('textextractor', TextExtractor()), #is it possible to pass 
                  my parameter ?
                 ('vectorizer', TfidfVectorizer(max_df=g['max_df'], 
                       min_df=g['min_df'], max_features=g['max_features'])),
                 ('clf', g['clf']), 
              ],
      )
  </code></pre>