features/signal_features.py
def signal_entropy(signal_df, channels):
    '''
    Calculate signal entropy of sensor signals.

    :param signal_df: Pandas DataFrame housing desired sensor signals
    :param channels: channels of signal to measure signal entropy
    :return: Pandas DataFrame housing calculated signal entropy for each signal channel
    '''
    signal_entropy_df = pd.DataFrame()

    for channel in channels:
        data_norm = signal_df[channel]/np.std(signal_df[channel])
        h, d = histogram(data_norm)

        lowerbound = d[0]
        upperbound = d[1]
        ncell = int(d[2])

        estimate = 0
        sigma = 0
        count = 0

        for n in range(ncell):
            if h[n] != 0:
                logf = np.log(h[n])
            else:
                logf = 0
            count = count + h[n]
            estimate = estimate - h[n] * logf
            sigma = sigma + h[n] * logf ** 2

        nbias = -(float(ncell) - 1) / (2 * count)

        estimate = estimate / count
        estimate = estimate + np.log(count) + np.log((upperbound - lowerbound) / ncell) - nbias

        # Scale the entropy estimate to stretch the range
        estimate = np.exp(estimate ** 2) - np.exp(0) - 1

        signal_entropy_df[channel + '_signal_entropy'] = [estimate]

    return signal_entropy_df

    Calculate signal entropy of sensor signals.

    :param signal_df: Pandas DataFrame housing desired sensor signals
    :param channels: channels of signal to measure signal entropy
    :return: Pandas DataFrame housing calculated signal entropy for each signal channel
    
Calculate signal entropy of sensor signals.
Calculate signal entropy of sensor signals .
def signal_entropy(signal_df, channels):
    signal_entropy_df = pd.DataFrame()
    for channel in channels:
        data_norm = signal_df[channel]/np.std(signal_df[channel])
        h, d = histogram(data_norm)
        lowerbound = d[0]
        upperbound = d[1]
        ncell = int(d[2])
        estimate = 0
        sigma = 0
        count = 0
        for n in range(ncell):
            if h[n] != 0:
                logf = np.log(h[n])
            else:
                logf = 0
            count = count + h[n]
            estimate = estimate - h[n] * logf
            sigma = sigma + h[n] * logf ** 2
        nbias = -(float(ncell) - 1) / (2 * count)
        estimate = estimate / count
        estimate = estimate + np.log(count) + np.log((upperbound - lowerbound) / ncell) - nbias
        estimate = np.exp(estimate ** 2) - np.exp(0) - 1
        signal_entropy_df[channel + '_signal_entropy'] = [estimate]
    return signal_entropy_df
def signal_entropy ( signal_df , channels ) : signal_entropy_df = pd . DataFrame ( ) for channel in channels : data_norm = signal_df [ channel ] / np . std ( signal_df [ channel ] ) h , d = histogram ( data_norm ) lowerbound = d [ 0 ] upperbound = d [ 1 ] ncell = int ( d [ 2 ] ) estimate = 0 sigma = 0 count = 0 for n in range ( ncell ) : if h [ n ] != 0 : logf = np . log ( h [ n ] ) else : logf = 0 count = count + h [ n ] estimate = estimate - h [ n ] * logf sigma = sigma + h [ n ] * logf ** 2 nbias = - ( float ( ncell ) - 1 ) / ( 2 * count ) estimate = estimate / count estimate = estimate + np . log ( count ) + np . log ( ( upperbound - lowerbound ) / ncell ) - nbias estimate = np . exp ( estimate ** 2 ) - np . exp ( 0 ) - 1 signal_entropy_df [ channel + '_signal_entropy' ] = [ estimate ] return signal_entropy_df
Calculate signal entropy of sensor signals.
Calculate signal entropy of sensor signals .
'''
    Calculate signal entropy of sensor signals.

    :param signal_df: Pandas DataFrame housing desired sensor signals
    :param channels: channels of signal to measure signal entropy
    :return: Pandas DataFrame housing calculated signal entropy for each signal channel
    ''' # Scale the entropy estimate to stretch the range
Pandas DataFrame housing calculated signal entropy for each signal channel
Pandas DataFrame housing calculated signal entropy for each signal channel
signal_df
Pandas DataFrame housing desired sensor signals
Pandas DataFrame housing desired sensor signals
channels
channels of signal to measure signal entropy
channels of signal to measure signal entropy