title: How to get feature importance in logistic regression using weights?
body: <p>I have a dataset of reviews which has a class label of positive/negative. I am applying Logistic regression to that reviews dataset. Firstly, I am converting into <strong>Bag of words</strong>. Here <strong>sorted_data['Text']</strong> is <strong>reviews</strong> and <strong>final_counts</strong> is a <strong>sparse matrix</strong></p>
  
  <pre><code>count_vect = CountVectorizer() 
  final_counts = count_vect.fit_transform(sorted_data['Text'].values)
  standardized_data = StandardScaler(with_mean=False).fit_transform(final_counts)
  </code></pre>
  
  <p>split the data set into train and test</p>
  
  <pre><code>X_1, X_test, y_1, y_test = cross_validation.train_test_split(final_counts, labels, test_size=0.3, random_state=0)
  X_tr, X_cv, y_tr, y_cv = cross_validation.train_test_split(X_1, y_1, test_size=0.3)
  </code></pre>
  
  <p>I am applying the logistic regression algorithm as follows</p>
  
  <pre><code>optimal_lambda = 0.001000
  log_reg_optimal = LogisticRegression(C=optimal_lambda)
  
  # fitting the model
  log_reg_optimal.fit(X_tr, y_tr)
  
  # predict the response
  pred = log_reg_optimal.predict(X_test)
  
  # evaluate accuracy
  acc = accuracy_score(y_test, pred) * 100
  print('\nThe accuracy of the Logistic Regression for C = %f is %f%%' % (optimal_lambda, acc))
  </code></pre>
  
  <p>My weights are</p>
  
  <pre><code>weights = log_reg_optimal.coef_ .   #&lt;class 'numpy.ndarray'&gt;
  
  array([[-0.23729528, -0.16050616, -0.1382504 , ...,  0.27291847,
           0.35857267,  0.41756443]])
  (1, 38178) #shape of weights
  </code></pre>
  
  <p>I want to get the feature importance i.e; top 100 features which have high weights. Could anyone tell me how to get them? </p>