简体   繁体   English

如何将(多元)时间序列加载到神经网络/LSTM

[英]how to load a (multivariate) timeseries into a neural network /LSTM

How can I load a time series such as:如何加载时间序列,例如:

在此处输入图片说明

into a neural network (LSTM).进入神经网络(LSTM)。 So far, I have seen approaches where this matrix is transposed ( https://github.com/curiousily/Getting-Things-Done-with-Pytorch/blob/master/06.time-series-anomaly-detection-ecg.ipynb ) (hours as columns, devices as rows).到目前为止,我已经看到了这个矩阵转置的方法( https://github.com/curiousily/Getting-Things-Done-with-Pytorch/blob/master/06.time-series-anomaly-detection-ecg.ipynb )(小时作为列,设备作为行)。 Others create a custom dataloader: http://www.feeny.org/custom-pytorch-dataset-class-for-timeseries-sequence-windows/ and manually create windows.其他人创建自定义数据加载器: http ://www.feeny.org/custom-pytorch-dataset-class-for-timeseries-sequence-windows/ 并手动创建窗口。

Why is there no more native way for the network to directly work on this raw input and learn the patterns / periodicity / anomalies?为什么网络没有更多的本地方式直接处理这个原始输入并学习模式/周期性/异常? How can this multivariate time-series of multiple devices be loaded natively into (pytorch, tensorflow) so that a resulting LSTM would properly learn:如何将多个设备的多元时间序列本地加载到(pytorch、tensorflow)中,以便生成的 LSTM 能够正确学习:

  • the state of an individual time-series (at least within some window, must not necessarily be the whole potentially infinite time-series)单个时间序列的状态(至少在某个窗口内,不一定是整个潜在的无限时间序列)

  • but also consider information of multiple series /devices / windows when performing a prediction但在执行预测时还要考虑多个系列/设备/窗口的信息

    import pandas as pd from pandas import Timestamp df = pd.DataFrame({'hour': {0: Timestamp('2020-01-01 00:00:00'), 1: Timestamp('2020-01-01 00:00:00'), 2: Timestamp('2020-01-01 00:00:00'), 3: Timestamp('2020-01-01 00:00:00'), 4: Timestamp('2020-01-01 00:00:00'), 5: Timestamp('2020-01-01 01:00:00'), 6: Timestamp('2020-01-01 01:00:00'), 7: Timestamp('2020-01-01 01:00:00'), 8: Timestamp('2020-01-01 01:00:00'), 9: Timestamp('2020-01-01 01:00:00')}, 'metrik_0': {0: 2.020883621337143, 1: 2.808770093182167, 2: 2.5267618429653402, 3: 3.2709845883575346, 4: 3.7984105853602235, 5: 4.0385160093937795, 6: 4.643267594258785, 7: 1.3012379179114388, 8: 3.509304898336378, 9: 2.8664748765561208}, 'metrik_1': {0: 4.580434685779621, 1: 2.933188328317023, 2: 3.999229120882797, 3: 2.9099857745449706, 4: 4.6302055552849, 5: 4.012670194672169, 6: 3.697352153313931, 7: 4.855210603371005, 8: 2.2197913449032254, 9: 2.393605868973481}, 'metrik_2': {0: 3.680527279150989, 1: 2.511065648719921, 2: 3.8350007982479113, 3: 2.4063786290320333, 4: 3.231433617897482, 5: 3.8505378854180115, 6: 5.359150077287063, 7: 2.8966469424805386, 8: 4.554080028058399, 9: 3.3319064764061914}, 'cohort_id': {0: 1, 1: 2, 2: 1, 3: 2, 4: 2, 5: 1, 6: 2, 7: 2, 8: 1, 9: 2}, 'device_id': {0: 1, 1: 3, 2: 4, 3: 2, 4: 5, 5: 4, 6: 3, 7: 2, 8: 1, 9: 5}})

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM