lime_text ========= .. py:module:: lime_text .. autoapi-nested-parse:: LIME text explainer. Classes ------- .. autoapisummary:: lime_text.LIMEText Module Contents --------------- .. py:class:: LIMEText(kernel_width=25, kernel=None, verbose=False, class_names=None, feature_selection='auto', split_expression='\\W+', bow=False, mask_string=None, random_state=None, char_level=False, preprocess_function=None) Wrapper around the LIME explainer. See Lime explainer by Marco Tulio Correia Ribeiro (https://github.com/marcotcr/lime). .. py:attribute:: preprocess_function :value: None .. py:attribute:: explainer .. py:method:: explain(model_or_function, input_text, labels, tokenizer=None, top_labels=None, num_features=10, num_samples=5000, **kwargs) Run the LIME explainer. :param model_or_function: The function that runs the model to be explained _or_ the path to a ONNX model on disk. :type model_or_function: callable or str :param tokenizer: Tokenizer class with tokenize and convert_tokens_to_string methods, and mask_token attribute :param input_text: Data to be explained :type input_text: np.ndarray :param labels: Iterable of indices of class to be explained :type labels: Iterable(int) :param top_labels: Top labels :param num_features: Number of features :type num_features: int :param num_samples: Number of samples :type num_samples: int :param kwargs: These parameters are passed on Other keyword arguments: see the LIME documentation for LimeTextExplainer.explain_instance: https://lime-ml.readthedocs.io/en/latest/lime.html#lime.lime_text.LimeTextExplainer.explain_instance. :returns: List of tuples (word, index of word in raw text, importance for target class) for each class .. py:method:: _reshape_result_for_single_label(local_explanation, string_map) :staticmethod: Get results for single label. :param local_explanation: Lime output, map of tuples (index, importance) :param string_map: Lime's IndexedString, see documentation: https://lime-ml.readthedocs.io/en/latest/lime.html?highlight=indexedstring#lime.lime_text.IndexedString