title: save binarizer together with sklearn model
body: <p>I'm trying to build a service that has 2 components. In component 1, I train a machine learning model using sklearn by creating a <code>Pipeline</code>. This model gets serialized using <code>joblib.dump</code> (really <code>numpy_pickle.dump</code>). Component 2 runs in the cloud, loads the model trained by (1), and uses it to label text that it gets as input. </p>
  
  <p>I'm running into an issue where, during training (component 1) I need to first binarize my data since it is text data, which means that the model is trained on binarized input and then makes predictions using the mapping created by the binarizer. I need to get this mapping back when (2) makes predictions based on the model so that I can output the actual text labels. </p>
  
  <p>I tried adding the binarizer to the pipeline like this, thinking that the model would then have the mapping itself:</p>
  
  <pre><code>p = Pipeline([
  ('binarizer', MultiLabelBinarizer()),
  ('vect', CountVectorizer(min_df=min_df, ngram_range=ngram_range)), 
  ('tfidf', TfidfTransformer()), 
  ('clf', OneVsRestClassifier(clf))
  ])
  </code></pre>
  
  <p>But I get the following error:</p>
  
  <pre><code>model = p.fit(training_features, training_tags)
  *** TypeError: fit_transform() takes 2 positional arguments but 3 were given
  </code></pre>
  
  <p>My goal is to make sure the binarizer and model are tied together so that the consumer knows how to decode the model's output.</p>
  
  <p>What are some existing paradigms for doing this? Should I be serializing the binarizer together with the model in some other object that I create? Is there some other way of passing the binarizer to <code>Pipeline</code> so that I don't have to do that, and would I be able to get the mappings back from the model if I did that? </p>