<commit_before>"""functions to create plots, basis for figures in article"""
import matplotlib.pyplot as plt
import seaborn as sns


def frame_error_rate(all_results_list):
    all_mn_test_err = []
    for el in all_results_list:
        all_mn_test_err.append(el['mn_test_err'])
    all_mn_test_err = np.asarray(all_mn_test_err)

    plt.style.use('ggplot')
    fig, ax = plt.subplots()
    for el in all_results_list:
        lbl = (el['bird_ID'])
        ax.plot(el['train_set_durs'],
                el['mn_test_err'],
                label=lbl,
                linestyle='--',
                marker='o')
    ax.plot(el['train_set_durs'], np.median(all_mn_test_err, axis=0),
            linestyle='--', marker='o', linewidth=3, color='k', label='median across birds')

    fig.set_size_inches(16, 8)
    plt.legend(fontsize=20)
    plt.xticks(el['train_set_durs'])
    plt.tick_params(axis='both', which='major', labelsize=20, rotation=45)
    plt.title('Frame error rate as a function of training set size', fontsize=40)
    plt.ylabel('Frame error rate\nas measured on test set', fontsize=32)
    plt.xlabel('Training set size: duration in s', fontsize=32);
    plt.tight_layout()
    plt.savefig('frame-err-rate-v-train-set-size.png')


def syllable_error_rate(all_results_list):
    plt.style.use('ggplot')
    fig, ax = plt.subplots()
    fig.set_size_inches(16, 8)
    for el in all_results_list:
        lbl = (el['bird_ID'])
        ax.plot(el['train_set_durs'],
                el['mn_test_syl_err'],
                label=lbl,
                linestyle=':',
                marker='o')

    plt.scatter(120, 0.84, s=75)
    plt.text(75, 0.7, 'Koumura & Okanoya 2016,\n0.84 note error rate\nwith 120s training data', fontsize=20)
    plt.scatter(480, 0.5, s=75)
    plt.text(355, 0.35, 'Koumura & Okanoya 2016,\n0.46 note error rate\nwith 480s training data', fontsize=20)

    plt.legend(fontsize=20, loc='upper right');
    plt.title('Syllable error rate as a function of training set size', fontsize=40)
    plt.xticks(el['train_set_durs'])
    plt.tick_params(axis='both', which='major', labelsize=20, rotation=45)
    plt.ylabel('Syllable error rate\nas measured on test set', fontsize=32)
    plt.xlabel('Training set size: duration in s', fontsize=32);
    plt.tight_layout()
    plt.savefig('syl-error-rate-v-train-set-size.png')<commit_msg>rewrite frame_error_rate function as frame_error_test_mn in article/plot.py<commit_after>"""functions to create plots, basis for figures in article"""
import matplotlib.pyplot as plt
import seaborn as sns

plt.style.use('ggplot')


def frame_error_test_mn_plot(df, save_as=None):
    ax = sns.stripplot(x="train_set_dur", y="frame_error_test_mean", data=df, size=12, alpha=0.75)
    sns.boxplot(x="train_set_dur", y="frame_error_test_mean", data=df, ax=ax, showfliers=False)
#    ax.set_ylabel("frame error, test set")
#    ax.set_xlabel("training set duration (s)")

    ax.set_title('Frame error rate as a function of training set size', fontsize=40)
    ax.set_ylabel('Frame error rate\nas measured on test set', fontsize=32)
    ax.set_xlabel('Training set size: duration in s', fontsize=32)

    if save_as:
        plt.savefig(save_as)

    return ax


def syllable_error_rate(all_results_list):
    plt.style.use('ggplot')
    fig, ax = plt.subplots()
    fig.set_size_inches(16, 8)
    for el in all_results_list:
        lbl = (el['bird_ID'])
        ax.plot(el['train_set_durs'],
                el['mn_test_syl_err'],
                label=lbl,
                linestyle=':',
                marker='o')

    plt.scatter(120, 0.84, s=75)
    plt.text(75, 0.7, 'Koumura & Okanoya 2016,\n0.84 note error rate\nwith 120s training data', fontsize=20)
    plt.scatter(480, 0.5, s=75)
    plt.text(355, 0.35, 'Koumura & Okanoya 2016,\n0.46 note error rate\nwith 480s training data', fontsize=20)

    plt.legend(fontsize=20, loc='upper right');
    plt.title('Syllable error rate as a function of training set size', fontsize=40)
    plt.xticks(el['train_set_durs'])
    plt.tick_params(axis='both', which='major', labelsize=20, rotation=45)
    plt.ylabel('Syllable error rate\nas measured on test set', fontsize=32)
    plt.xlabel('Training set size: duration in s', fontsize=32);
    plt.tight_layout()
    plt.savefig('syl-error-rate-v-train-set-size.png')
{'fraction_non_alphanumeric': 0.13793900184842883, 'fraction_numerical': 0.036044362292051754, 'mean_word_length': 3.430910951893552, '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': '5174703', 'n_tokens_mistral': 1667, 'n_tokens_neox': 1535, 'n_words': 334}