<commit_before>from DSTK.FeatureBinning import TreeBasedFeatureBinning as tfb
import matplotlib.pyplot as plt
import numpy as np


def plot_binner(binner, class_labels={0: '0', 1: '1'}):
    assert isinstance(binner, tfb.TreeBasedFeatureBinning)

    class_0 = [tup[1][0] for tup in binner.cond_proba_buckets]
    class_1 = [tup[1][1] for tup in binner.cond_proba_buckets]
    label = [str(tup[0]).replace(')',']') for tup in binner.cond_proba_buckets]
    ind = np.arange(len(class_0))
    w = 0.5
    plt.bar(ind, class_0, w, label=class_labels[0])
    plt.bar(ind, class_1, w, bottom=class_0, color='g', label=class_labels[1])
    plt.xticks(ind + w/2., label, size=16, rotation=75)
    plt.yticks(size=16)
    plt.legend(fontsize=16)
    plt.title(binner.name, size=16)
    plt.xlabel('bucket', size=18)
    plt.ylabel('cond. proba.', size=18)
    plt.tight_layout()<commit_msg>Update plotting.py<commit_after>from DSTK.FeatureBinning import TreeBasedFeatureBinning as tfb
import matplotlib.pyplot as plt
import numpy as np


def plot_binner(binner, class_labels={0: '0', 1: '1'}):
    assert isinstance(binner, tfb.TreeBasedFeatureBinning)

    class_0 = [tup[1][0] for tup in binner.cond_proba_buckets]
    class_1 = [tup[1][1] for tup in binner.cond_proba_buckets]
    label = [str(tup[0]).replace(')',']') for tup in binner.cond_proba_buckets]
    ind = np.arange(len(class_0))
    w = 0.5
    plt.bar(ind, class_0, w, label=class_labels[0])
    plt.bar(ind, class_1, w, bottom=class_0, color='g', label=class_labels[1])
    plt.xticks(ind + w/2., label, size=16, rotation=75)
    plt.yticks(size=16)
    plt.legend(fontsize=16)
    plt.title(binner.name, size=16)
    plt.xlabel('bucket', size=18)
    plt.ylabel('cond. proba.', size=18)ß
{'fraction_non_alphanumeric': 0.1511161991986262, 'fraction_numerical': 0.038923869490555235, 'mean_word_length': 4.47962382445141, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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}}
{'dir': 'git-commits-cleaned', 'id': '3198109', 'n_tokens_mistral': 721, 'n_tokens_neox': 690, 'n_words': 139}