code: def explain_weights_sklearn_crfsuite(
      crf,
      top=20,
      target_names=None,
      targets=None,
      feature_re=None,
      feature_filter=None,
  ):
      """Explain sklearn_crfsuite.CRF weights.
  
      See :func:`eli5.explain_weights` for description of
      ``top``, ``target_names``, ``targets``,
      ``feature_re`` and ``feature_filter`` parameters.
      """
      feature_names = np.array(crf.attributes_)
      state_coef = crf_state_coef(crf).todense().A
      transition_coef = crf_transition_coef(crf)
  
      if feature_filter is not None or feature_re is not None:
          state_feature_names, flt_indices = FeatureNames(
              feature_names
          ).handle_filter(feature_filter, feature_re)
          state_feature_names = np.array(
              state_feature_names.feature_names
          )
          state_coef = state_coef[:, flt_indices]
      else:
          state_feature_names = feature_names
  
      def _features(label_id):
          return get_top_features(
              state_feature_names, state_coef[label_id], top
          )
  
      if targets is None:
          targets = sorted_for_ner(crf.classes_)
  
      display_names = get_target_display_names(
          crf.classes_, target_names, targets
      )
      indices, names = zip(*display_names)
      transition_coef = filter_transition_coefs(
          transition_coef, indices
      )
  
      return Explanation(
          targets=[
              TargetExplanation(
                  target=label, feature_weights=_features(label_id)
              )
              for label_id, label in zip(indices, names)
          ],
          transition_features=TransitionFeatureWeights(
              class_names=names,
              coef=transition_coef,
          ),
          estimator=repr(crf),
          method="CRF",
      )
  
file_path: eli5/eli5/sklearn_crfsuite/explain_weights.py
imports: from __future__ import absolute_import
  import numpy
  from scipy import sparse
  from sklearn_crfsuite import CRF
  from eli5.base import Explanation, TargetExplanation, TransitionFeatureWeights
  from eli5.explain import explain_weights
  from eli5.utils import get_target_display_names
  from eli5._feature_names import FeatureNames
  from eli5._feature_weights import get_top_features
label_desc: Use image node_id 1 for calling a global function with example usage: explain_weights_sklearn_crfsuite(crf, top, target_names, targets, feature_re, feature_filter) and returns: Explanation, get_top_features