title: Using Scikit's LabelEncoder correctly across multiple programs
body: <p>The basic task that I have at hand is</p>
  
  <p>a) Read some tab separated data.</p>
  
  <p>b) Do some basic preprocessing</p>
  
  <p>c) For each categorical column use <code>LabelEncoder</code> to create a mapping. This is don somewhat like this</p>
  
  <pre><code>mapper={}
  #Converting Categorical Data
  for x in categorical_list:
       mapper[x]=preprocessing.LabelEncoder()
  
  for x in categorical_list:
       df[x]=mapper[x].fit_transform(df.__getattr__(x))
  </code></pre>
  
  <p>where <code>df</code> is a pandas dataframe and <code>categorical_list</code> is a list of column headers that need to be transformed.</p>
  
  <p>d) Train a classifier and save it to disk using <code>pickle</code></p>
  
  <p>e) Now in a different program, the model saved is loaded. </p>
  
  <p>f) The test data is loaded and the same preprocessing is performed.</p>
  
  <p>g) The <code>LabelEncoder's</code> are used for converting categorical data.</p>
  
  <p>h) The model is used to predict.</p>
  
  <p>Now the question that I have is, will the step <code>g)</code> work correctly?</p>
  
  <p>As the documentation for <code>LabelEncoder</code> says</p>
  
  <pre><code>It can also be used to transform non-numerical labels (as long as 
  they are hashable and comparable) to numerical labels.
  </code></pre>
  
  <p>So will each entry hash to the exact same value everytime? </p>
  
  <p>If No, what is a good way to go about this. Any way to retrive the mappings of the encoder? Or an altogether different way from LabelEncoder?</p>