<jupyter_start><jupyter_text>LIME in UseTo simplify the use of LIME, TIC provides a wrapper.  Preparation<jupyter_code>%load_ext autoreload
%autoreload 2
import pickle

from tic import load_test_data
from tic.interpret.lime import explain_local, explain_global
test_data = load_test_data()

class_names = test_data['target_names']
feature_names = test_data['feature_names']
instance = test_data['dataset']['X_test'].sample(1).values[0]
clf = pickle.load(open('.classifiers/logistic_regression.clf', 'rb'))<jupyter_output><empty_output><jupyter_text>Explain a single instance<jupyter_code>explain_local(
    clf=clf,
    instance=instance,
    training_data=test_data['dataset']['X_train'],
    feature_names=feature_names,
    class_names=class_names,
    explanation_kwargs={'num_features': 5}
)<jupyter_output><empty_output><jupyter_text>Create an explanation for the whole dataset<jupyter_code>explain_global(
    clf=clf,
    training_data=test_data['dataset']['X_train'],
    feature_names=feature_names,
    class_names=class_names,
    explanation_kwargs={'sample_size': 100}
)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11220825852782765, 'fraction_numerical': 0.0062836624775583485, 'mean_word_length': 8.065040650406504, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '158170', 'license': 'MIT', 'n_tokens_mistral': 391, 'n_tokens_neox': 385, 'n_words': 62, 'path': 'examples/03_LIME.ipynb', 'repo_name': 'tommartensen/tic', 'size': '1114'}