0

Make a bar chart

plt.bar(x_values,importances,orientation = 'vertical')

Tick labels for x axis

plt.xticks(x_values,feature_list, rotation='vertical')

Axis labels and title

plt.ylabel('Importance'); plt.xlabel('Variable'); plt.title('Variable Importances');

Output I am getting:

enter image description here

Community
  • 1
  • 1
  • Too many features for that size. You can resize the window or plot using more DPI or another figure size. – Joe Jun 10 '20 at 05:00
  • Or spread across two subplots, maybe sort by size and use different y scales for them. – Joe Jun 10 '20 at 05:02
  • https://stackoverflow.com/questions/55347378/how-to-fix-overlapping-matplotlib-y-axis-tick-labels-or-autoscale-the-plot?noredirect=1&lq=1 – Joe Jun 10 '20 at 05:04
  • @Joe Thanks for your help. I want to plot top 10 features. The rest can be ignored. Can you please help me with that? – CoffeeCode Jun 10 '20 at 13:48
  • https://numpy.org/doc/stable/reference/generated/numpy.sort.html – Joe Jun 10 '20 at 13:59
  • https://stackoverflow.com/questions/2828059/sorting-arrays-in-numpy-by-column – Joe Jun 10 '20 at 14:00
  • you might need numpy.argsort as you have to sort the features array and then apply the same sorting on the names. Maybe it is easier for you to use Pandas. – Joe Jun 10 '20 at 14:01
  • https://stackoverflow.com/questions/37787698/how-to-sort-pandas-dataframe-from-one-column – Joe Jun 10 '20 at 14:01
  • https://pandas.pydata.org/pandas-docs/version/0.19/generated/pandas.DataFrame.sort.html – Joe Jun 10 '20 at 14:01

0 Answers0