问题描述
我正在尝试解决上述 kaggle 问题,我想将预处理数据导出到 CSV,以便我可以在 weka 上构建模型,但是当我尝试将其保存在 CSV 中时,我丢失了一个维度,我想保留该 CSV 中的所有信息。 这是一个基于时间序列的数据
请帮助我提供相关代码或任何资源。
谢谢
print (scaled_x)
|x |y |z |label
|1.485231 |-0.661030 |-1.194153 |0
|0.888257 |-1.370361 |-0.829636 |0
|0.691523 |-0.594794 |-0.936247 |0
Fs=20
frame_size = Fs*4 #80
hop_size = Fs*2 #40
def get_frames(df,frame_size,hop_size):
N_FEATURES = 3
frames = []
labels = []
for i in range(0,len(df )- frame_size,hop_size):
x = df['x'].values[i: i+frame_size]
y = df['y'].values[i: i+frame_size]
z = df['z'].values[i: i+frame_size]
label = stats.mode(df['label'][i: i+frame_size])[0][0]
frames.append([x,y,z])
labels.append(label)
frames = np.asarray(frames).reshape(-1,N_FEATURES)
labels = np.asarray(labels)
return frames,labels
x,y = get_frames(scaled_x,hop_size)
x.shape,y.shape
((78728,80,3),(78728,))
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)