code: def plot_feature_effects():
      # learned coefficients weighted by frequency of appearance
      average_feature_effects = (
          clf.coef_ * np.asarray(X_train.mean(axis=0)).ravel()
      )
  
      for i, label in enumerate(target_names):
          top5 = np.argsort(average_feature_effects[i])[-5:][::-1]
          if i == 0:
              top = pd.DataFrame(feature_names[top5], columns=[label])
              top_indices = top5
          else:
              top[label] = feature_names[top5]
              top_indices = np.concatenate(
                  (top_indices, top5), axis=None
              )
      top_indices = np.unique(top_indices)
      predictive_words = feature_names[top_indices]
  
      # plot feature effects
      bar_size = 0.25
      padding = 0.75
      y_locs = np.arange(len(top_indices)) * (4 * bar_size + padding)
  
      fig, ax = plt.subplots(figsize=(10, 8))
      for i, label in enumerate(target_names):
          ax.barh(
              y_locs + (i - 2) * bar_size,
              average_feature_effects[i, top_indices],
              height=bar_size,
              label=label,
          )
      ax.set(
          yticks=y_locs,
          yticklabels=predictive_words,
          ylim=[
              0 - 4 * bar_size,
              len(top_indices) * (4 * bar_size + padding)
              - 4 * bar_size,
          ],
      )
      ax.legend(loc="lower right")
  
      print("top 5 keywords per class:")
      print(top)
  
      return ax
  
file_path: scikit-learn/examples/text/plot_document_classification_20newsgroups.py
imports: from time import time
  from sklearn.datasets import fetch_20newsgroups
  from sklearn.feature_extraction.text import TfidfVectorizer
  from sklearn.linear_model import RidgeClassifier
  import matplotlib.pyplot
  from sklearn.metrics import ConfusionMatrixDisplay
  import numpy
  import pandas
  from sklearn import metrics
  from sklearn.utils.extmath import density
  from sklearn.ensemble import RandomForestClassifier
  from sklearn.linear_model import LogisticRegression, SGDClassifier
  from sklearn.naive_bayes import ComplementNB
  from sklearn.neighbors import KNeighborsClassifier, NearestCentroid
  from sklearn.svm import LinearSVC
label_desc: Use image node_id 3 for calling a global function with example usage: plot_feature_effects() and returns: ax