I'm a novice in python trying to learn how to extract the top 10 and the bottom 10 from the list that I created with this code:
clftest = logres1.fit(X_train,y_train)
#getting the feature's coefficient
feature_importance = clftest.coef_[0]
#creating an array to identify the highest and lowest value
sorter = np.argsort(feature_importance)
#using the shape of sorter, arrange it from lowest to highest
position = np.arange(sorter.shape[0])
featfig = plt.figure(figsize=(100,100))
featax = featfig.add_subplot(1, 1, 1)
featax.barh(position, feature_importance[sorter], align="center")
featax.set_yticks(position)
featax.set_yticklabels(np.array(X.columns)[sorter], fontsize=8)
plt.show()
As you can see there's a lot of features involve in my graph...
Also, I wonder if there's a shorthand for this one or if this is already the shortest line of code..
