title: Display name of 'one-hot-encoded' variables for 'feature Importance'
body: <p>How can I properly display the name of the 'one-hot-encoded' features after finishing the training and validation of my algorithm? I want to neatly display the name of each feature along with their importance. Below is what I've tried:</p>
  
  <p><strong>Display feature importance:</strong></p>
  
  <pre><code>grid_search.best_estimator_.feature_importances_
  array([  7.67359589e-02,   7.20731884e-02,   4.38667330e-02,
           1.69222269e-02,   1.51816327e-02,   1.66947835e-02,
           1.56858183e-02,   3.43347923e-01,   5.95555727e-02,
           7.65422356e-02,   1.11224727e-01,   1.02677088e-02,
           1.32720377e-01,   1.06447326e-04,   4.45207929e-03,
           4.62258699e-03])
  </code></pre>
  
  <p><strong>Get one-hot category names:</strong></p>
  
  <pre><code>cat_one_hot_attribs = list(encoder.classes_)
  print(cat_one_hot_attribs)
  ['&lt;1H OCEAN', 'INLAND', 'ISLAND', 'NEAR BAY', 'NEAR OCEAN']
  </code></pre>
  
  <p><strong>Get rest of names (other categories):</strong></p>
  
  <pre><code>num_attribs = list(X_train)
  
  ['longitude',
   'latitude',
   'housing_median_age',
   'total_rooms',
   'total_bedrooms',
   'population',
   'households',
   'median_income',
   'rooms_per_household',
   'bedrooms_per_household',
   'population_per_household',
   0,
   1,
   2,
   3,
   4]
  </code></pre>
  
  <p><strong>Now I do the following:</strong></p>
  
  <pre><code>attributes = num_attribs + cat_one_hot_attribs
  
  print(pd.DataFrame(sorted(zip(feature_importance, attributes), reverse=True)))
  </code></pre>
  
  <p><strong>But I get the following:</strong></p>
  
  <pre><code>         0                         1
  0   0.343348             median_income
  1   0.132720                         1
  2   0.111225  population_per_household
  3   0.076736                 longitude
  4   0.076542    bedrooms_per_household
  5   0.072073                  latitude
  6   0.059556       rooms_per_household
  7   0.043867        housing_median_age
  8   0.016922               total_rooms
  9   0.016695                population
  10  0.015686                households
  11  0.015182            total_bedrooms
  12  0.010268                         0
  13  0.004623                         4
  14  0.004452                         3
  15  0.000106                         2
  </code></pre>
  
  <p>I have tried other ways as well but all have failed. </p>
  
  <p>Can someone please suggest a way to get this displaying properly? Thank you.</p>
  
  <p><strong>Edit:</strong></p>
  
  <p>From @cᴏʟᴅsᴘᴇᴇᴅ 's answer, I tried the following:</p>
  
  <pre><code>feature_importance = grid_search.best_estimator_.feature_importances_
  
  cat_one_hot_attribs = list(encoder.classes_)
  
  num_attribs = list(X_train)
  attributes = num_attribs + cat_one_hot_attribs
  
  vals = sorted(zip(feature_importance, attributes), key=lambda x: x[0], reverse=True)
  df = pd.DataFrame(vals)
  print(df)
  </code></pre>
  
  <p>Still getting output as above.</p>