4.7 - ACE/Analysis/models.py
def calculate_ce_fluctuation_set_windows(self, contribution_windows, toks, limit=None):
        """
        Method for calculating the cross entropy of a given set of contributions, which has already been split into windows.
        :param contribution_windows: This is a series of dataframes (one for each window). These must be the same as the snapshot windows.
        :returns: a dictionary of the cross-entropies for each window.
        """
        # Initialise output
        cross_entropies = dict()

        all_windows = list(contribution_windows.keys())

        # Loop through each window in the data, as well as the next window
        for curr_window, next_window in zip(all_windows[:-1], all_windows[1:]):
            # Get the contributions for the next window
            next_contributions = contribution_windows[next_window]

            # Get the current tokenised contributions for the window
            next_toks = toks[next_contributions.index]

            # Calculate cross-entropy for the current lot of tokens
            cross_entropies[next_window] = next_toks.apply(lambda x: self.snapshots[curr_window].get_cross_entropy(x[:limit]))

        return cross_entropies

        Method for calculating the cross entropy of a given set of contributions, which has already been split into windows.
        :param contribution_windows: This is a series of dataframes (one for each window). These must be the same as the snapshot windows.
        :returns: a dictionary of the cross-entropies for each window.
        
Method for calculating the cross entropy of a given set of contributions, which has already been split into windows.
Method for calculating the cross entropy of a given set of contributions which has already been split into windows .
def calculate_ce_fluctuation_set_windows(self, contribution_windows, toks, limit=None):
        cross_entropies = dict()
        all_windows = list(contribution_windows.keys())
        for curr_window, next_window in zip(all_windows[:-1], all_windows[1:]):
            next_contributions = contribution_windows[next_window]
            next_toks = toks[next_contributions.index]
            cross_entropies[next_window] = next_toks.apply(lambda x: self.snapshots[curr_window].get_cross_entropy(x[:limit]))
        return cross_entropies
def calculate_ce_fluctuation_set_windows ( self , contribution_windows , toks , limit = None ) : cross_entropies = dict ( ) all_windows = list ( contribution_windows . keys ( ) ) for curr_window , next_window in zip ( all_windows [ : - 1 ] , all_windows [ 1 : ] ) : next_contributions = contribution_windows [ next_window ] next_toks = toks [ next_contributions . index ] cross_entropies [ next_window ] = next_toks . apply ( lambda x : self . snapshots [ curr_window ] . get_cross_entropy ( x [ : limit ] ) ) return cross_entropies
Method for calculating the cross entropy of a given set of contributions, which has already been split into windows.
Method for calculating the cross entropy of a given set of contributions which has already been split into windows .
"""
        Method for calculating the cross entropy of a given set of contributions, which has already been split into windows.
        :param contribution_windows: This is a series of dataframes (one for each window). These must be the same as the snapshot windows.
        :returns: a dictionary of the cross-entropies for each window.
        """ # Initialise output # Loop through each window in the data, as well as the next window # Get the contributions for the next window # Get the current tokenised contributions for the window # Calculate cross-entropy for the current lot of tokens
a dictionary of the cross-entropies for each window.
a dictionary of the cross - entropies for each window .
self
contribution_windows
This is a series of dataframes (one for each window). These must be the same as the snapshot windows.
This is a series of dataframes ( one for each window ) . These must be the same as the snapshot windows .
toks
limit