コード例 #1
0
def build_feat(data, add_feat,window_length=20):
    ## use other available channels
    feat_mean = np.nan_to_num(pd.rolling_mean(data,5))
    feat_mean = signal_preproc.rolling_window(feat_mean, window_length)
    feat_std = np.nan_to_num(pd.rolling_std(data,5))
    feat_std = signal_preproc.rolling_window(feat_std, window_length)
    feat_diff = np.append(0,np.diff(data))
    feat_diff = signal_preproc.rolling_window(feat_diff,window_length)
    feat_grad = [np.gradient(i) for i in signal_preproc.rolling_window(data,window_length)]
    feat_orig = signal_preproc.rolling_window(data,window_length)
    feat_2ndgrad = [np.gradient(i,2) for i in signal_preproc.rolling_window(data,window_length)]
    feat_gmean = [clf.RunningGMean(i) for i in signal_preproc.rolling_window(data,window_length)]
    feat_ii = signal_preproc.rolling_window(add_feat, window_length)
    feat = np.hstack((feat_orig,feat_mean,feat_std,feat_diff,feat_grad,feat_2ndgrad,feat_gmean,feat_ii))
    feat = feat.reshape(-1,8,window_length)
    feat = feat.astype('float32')
    return feat
コード例 #2
0
def get_target(data,window_length=20):
    target = signal_preproc.labels(signal_preproc.rolling_window(data,window_length))
    target = np.atleast_2d(np.asarray(target)).T
    target = target.astype('float32')
    return target