class_docstr: Intent classifier which uses a Logistic Regression underneath
class_docstr_tok: ["Intent","classifier","which","uses","a","Logistic","Regression","underneath"]
code: def log_activation_weights(self, text, x, top_n=50):
      import numpy as np
  
      if not hasattr(self.featurizer, "feature_index_to_feature_name"):
          return None
  
      log = '\n\nTop {} feature activations for: "{}":\n'.format(
          top_n, text
      )
      activations = np.multiply(
          self.classifier.coef_, np.asarray(x.todense())
      )
      abs_activation = np.absolute(activations).flatten().squeeze()
  
      if top_n > activations.size:
          top_n = activations.size
  
      top_n_activations_ix = np.argpartition(
          abs_activation, -top_n, axis=None
      )[-top_n:]
      top_n_activations_ix = np.unravel_index(
          top_n_activations_ix, activations.shape
      )
  
      index_to_feature = self.featurizer.feature_index_to_feature_name
      features_intent_and_activation = [
          (self.intent_list[i], index_to_feature[f], activations[i, f])
          for i, f in zip(*top_n_activations_ix)
      ]
  
      features_intent_and_activation = sorted(
          features_intent_and_activation,
          key=lambda x: abs(x[2]),
          reverse=True,
      )
  
      for intent, feature, activation in features_intent_and_activation:
          log += '\n\n"{}" -> ({}, {:.2f})'.format(
              intent, feature, float(activation)
          )
      log += "\n\n"
      return log
  
imports: from __future__ import unicode_literals
  import json
  import logging
  from builtins import range, str, zip
  from pathlib import Path
  from snips_nlu.common.log_utils import DifferedLoggingMessage, log_elapsed_time
  from snips_nlu.common.utils import check_persisted_path, fitted_required, json_string
  from snips_nlu.constants import LANGUAGE, RES_PROBA
  from snips_nlu.dataset import validate_and_format_dataset
  from snips_nlu.exceptions import LoadingError, _EmptyDatasetUtterancesError
  from snips_nlu.intent_classifier.featurizer import Featurizer
  from snips_nlu.intent_classifier.intent_classifier import IntentClassifier
  from snips_nlu.intent_classifier.log_reg_classifier_utils import build_training_data, get_regularization_factor, text_to_utterance
  from snips_nlu.pipeline.configs import LogRegIntentClassifierConfig
  from snips_nlu.result import intent_classification_result
label_desc: Use image node_id 11 for calling the LogRegIntentClassifier obj's underlying member method code with example usage: obj.log_activation_weights(text, x, top_n) and returns: log, None