-1

Im using this code from Sci Kit Learns website for a regression algorithm and then plotting Deviance & variable importance with matplotlib.

[Sci Kit Learn Gradient Boost regression][1]

The Sci Kit Learn examples the famous Boston housing project data set that is built into the Sci Kit Learn Package when data is plotted matplotlib references boston.feature_names and I am trying to find away around this with my Pandas data frame.

plt.yticks(pos, boston.feature_names[sorted_idx])

Can this be retrofitted for Y ticks to be my column header name in my Pandas dataframe?

bbartling
  • 3,288
  • 9
  • 43
  • 88
  • If you want to ask about some undesired behaviour in a code you need to provide a [mcve], i.e. a runnable example. – ImportanceOfBeingErnest Mar 13 '18 at 16:15
  • Ok Ill modify the post.. And I think the answer is here in this post https://stackoverflow.com/questions/43717739/matplotlib-set-xticks-to-column-labels-to-corresponding-index – bbartling Mar 13 '18 at 16:46
  • You can decide: If you solved the issue with the linked post, you can either delete this question, or mark it as duplicate. If it isn't solved, but you have the impression that this post helps, explain the difference in the question. – ImportanceOfBeingErnest Mar 13 '18 at 16:53

1 Answers1

0

This will reference the pandas dataframe column names:

plt.yticks(pos, df.columns.values) 
bbartling
  • 3,288
  • 9
  • 43
  • 88