Right now I have this, listing feature importances as numbers, how can i put the column names in the x axis?
from sklearn.datasets import make_classification
from sklearn.linear_model import LogisticRegression
from matplotlib import pyplot
X, y = make_classification(n_samples=2700, n_features=60,
n_informative=5, n_redundant=5, random_state=1)
model = LogisticRegression()
model.fit(X, y)
importance = model.coef_[0]
for i,v in enumerate(importance):
print('Feature: %0d, Score: %.5f' % (i,v))
pyplot.bar([x for x in range(len(importance))], importance)
pyplot.show()
The Output:
Feature: 0, Score: -0.11124
Feature: 1, Score: -0.04292
Feature: 2, Score: 0.00561