features/signal_features.py
def mean_cross_rate(signal_df, channels):
    '''
    Compute mean cross rate of sensor signals.

    :param signal_df: Pandas DataFrame housing desired sensor signals
    :param channels: channels of signal to measure mean cross rate
    :return: Pandas DataFrame housing calculated mean cross rate for each signal channel
    '''
    mean_cross_rate_df = pd.DataFrame()
    signal_df_mean = signal_df[channels] - signal_df[channels].mean()

    for channel in channels:
        MCR = 0

        for i in range(len(signal_df_mean) - 1):
            if np.sign(signal_df_mean.loc[i, channel]) != np.sign(signal_df_mean.loc[i + 1, channel]):
                MCR += 1

        MCR = float(MCR) / len(signal_df_mean)

        mean_cross_rate_df[channel + '_mean_cross_rate'] = [MCR]

    return mean_cross_rate_df

    Compute mean cross rate of sensor signals.

    :param signal_df: Pandas DataFrame housing desired sensor signals
    :param channels: channels of signal to measure mean cross rate
    :return: Pandas DataFrame housing calculated mean cross rate for each signal channel
    
Compute mean cross rate of sensor signals.
Compute mean cross rate of sensor signals .
def mean_cross_rate(signal_df, channels):
    mean_cross_rate_df = pd.DataFrame()
    signal_df_mean = signal_df[channels] - signal_df[channels].mean()
    for channel in channels:
        MCR = 0
        for i in range(len(signal_df_mean) - 1):
            if np.sign(signal_df_mean.loc[i, channel]) != np.sign(signal_df_mean.loc[i + 1, channel]):
                MCR += 1
        MCR = float(MCR) / len(signal_df_mean)
        mean_cross_rate_df[channel + '_mean_cross_rate'] = [MCR]
    return mean_cross_rate_df
def mean_cross_rate ( signal_df , channels ) : mean_cross_rate_df = pd . DataFrame ( ) signal_df_mean = signal_df [ channels ] - signal_df [ channels ] . mean ( ) for channel in channels : MCR = 0 for i in range ( len ( signal_df_mean ) - 1 ) : if np . sign ( signal_df_mean . loc [ i , channel ] ) != np . sign ( signal_df_mean . loc [ i + 1 , channel ] ) : MCR += 1 MCR = float ( MCR ) / len ( signal_df_mean ) mean_cross_rate_df [ channel + '_mean_cross_rate' ] = [ MCR ] return mean_cross_rate_df
Compute mean cross rate of sensor signals.
Compute mean cross rate of sensor signals .
'''
    Compute mean cross rate of sensor signals.

    :param signal_df: Pandas DataFrame housing desired sensor signals
    :param channels: channels of signal to measure mean cross rate
    :return: Pandas DataFrame housing calculated mean cross rate for each signal channel
    '''
Pandas DataFrame housing calculated mean cross rate for each signal channel
Pandas DataFrame housing calculated mean cross rate for each signal channel
signal_df
Pandas DataFrame housing desired sensor signals
Pandas DataFrame housing desired sensor signals
channels
channels of signal to measure mean cross rate
channels of signal to measure mean cross rate