4.7 - ACE/Analysis/sampling_over_time.py
def calculate_CE_per_group(samples, test_contribs, test_toks, group_names, all_groups_toks, n_words_per_contrib):
    """
    Calculates the Cross-Entropy between each combination of groups.

    :param samples: contributions for training snapshot models.
    :param test_contribs: contributions for comparing to snapshots.
    :param test_toks: tokens of test contributions.
    :param group_names: all the names of groups.
    :param all_groups_toks: all tokens, an entry for each group, in the same order as group names.
    :param n_words_per_contrib: the number of words to use from each contribution.

    :returns: The Cross-Entropies of each group against the snapshot model of each group.
    """
    # Initialises the dictionary of cross entropies per group for this run.
    all_groups_CE = {gname: {} for gname in group_names}

    # Loop through each group to train a snapshot model and compare the contributions of all groups to that snapshot.
    for i in range(len(group_names)):
        # Create snapshot model using the snapshot samples for the current group.
        snaps = SnapshotModelsPreset(samples[group_names[i]], all_groups_toks[i].apply(lambda x: x[:n_words_per_contrib]))
        # Loop through each group.
        for gname in group_names:
            # Calculate the cross entropy for each of the test samples
            all_groups_CE[group_names[i]][gname] = snaps.calculate_cross_entropies(test_toks[gname].apply(lambda x: x[:n_words_per_contrib]), test_contribs[gname].date)

    return all_groups_CE

    Calculates the Cross-Entropy between each combination of groups.

    :param samples: contributions for training snapshot models.
    :param test_contribs: contributions for comparing to snapshots.
    :param test_toks: tokens of test contributions.
    :param group_names: all the names of groups.
    :param all_groups_toks: all tokens, an entry for each group, in the same order as group names.
    :param n_words_per_contrib: the number of words to use from each contribution.

    :returns: The Cross-Entropies of each group against the snapshot model of each group.
    
Calculates the Cross-Entropy between each combination of groups.
Calculates the Cross - Entropy between each combination of groups .
def calculate_CE_per_group(samples, test_contribs, test_toks, group_names, all_groups_toks, n_words_per_contrib):
    all_groups_CE = {gname: {} for gname in group_names}
    for i in range(len(group_names)):
        snaps = SnapshotModelsPreset(samples[group_names[i]], all_groups_toks[i].apply(lambda x: x[:n_words_per_contrib]))
        for gname in group_names:
            all_groups_CE[group_names[i]][gname] = snaps.calculate_cross_entropies(test_toks[gname].apply(lambda x: x[:n_words_per_contrib]), test_contribs[gname].date)
    return all_groups_CE
def calculate_CE_per_group ( samples , test_contribs , test_toks , group_names , all_groups_toks , n_words_per_contrib ) : all_groups_CE = { gname : { } for gname in group_names } for i in range ( len ( group_names ) ) : snaps = SnapshotModelsPreset ( samples [ group_names [ i ] ] , all_groups_toks [ i ] . apply ( lambda x : x [ : n_words_per_contrib ] ) ) for gname in group_names : all_groups_CE [ group_names [ i ] ] [ gname ] = snaps . calculate_cross_entropies ( test_toks [ gname ] . apply ( lambda x : x [ : n_words_per_contrib ] ) , test_contribs [ gname ] . date ) return all_groups_CE
Calculates the Cross-Entropy between each combination of groups.
Calculates the Cross - Entropy between each combination of groups .
"""
    Calculates the Cross-Entropy between each combination of groups.

    :param samples: contributions for training snapshot models.
    :param test_contribs: contributions for comparing to snapshots.
    :param test_toks: tokens of test contributions.
    :param group_names: all the names of groups.
    :param all_groups_toks: all tokens, an entry for each group, in the same order as group names.
    :param n_words_per_contrib: the number of words to use from each contribution.

    :returns: The Cross-Entropies of each group against the snapshot model of each group.
    """ # Initialises the dictionary of cross entropies per group for this run. # Loop through each group to train a snapshot model and compare the contributions of all groups to that snapshot. # Create snapshot model using the snapshot samples for the current group. # Loop through each group. # Calculate the cross entropy for each of the test samples
The Cross-Entropies of each group against the snapshot model of each group.
The Cross - Entropies of each group against the snapshot model of each group .
samples
contributions for training snapshot models.
contributions for training snapshot models .
test_contribs
contributions for comparing to snapshots.
contributions for comparing to snapshots .
test_toks
tokens of test contributions.
tokens of test contributions .
group_names
all the names of groups.
all the names of groups .
all_groups_toks
all tokens, an entry for each group, in the same order as group names.
all tokens an entry for each group in the same order as group names .
n_words_per_contrib
the number of words to use from each contribution.
the number of words to use from each contribution .