python - 信号开发/猎户座改变 TadGAN 的窗口大小
问题描述
我正在使用本文中引用的 Orion 对于 tadGAN 管道,我无法更改 window_size(用于调整模型),如下面的代码所示。这适用于这个包中的其他模型(带阈值的 LSTM 工作正常)
任何想法为什么?
(Google Colab 中的可重现示例)
! pip install orion-ml 'urllib3>=1.25.4,<1.26'
# to get tadgan.json
%%bash
rm -rf Orion
rm -rf images
git clone https://github.com/signals-dev/Orion.git
mv Orion/notebooks/tulog/* .
exit
# Packages
from orion import Orion
from orion.data import load_signal
import shutil
# Move json into working directory
shutil.copy("/content/Orion/orion/pipelines/verified/tadgan/tadgan.json", "/content")
shutil.copy("/content/Orion/orion/pipelines/verified/lstm_dynamic_threshold/lstm_dynamic_threshold.json", "/content")
# Select data
signal = 'nyc_taxi'
# load signal
df = load_signal(signal)
parameters = {
"mlprimitives.custom.timeseries_preprocessing.time_segments_aggregate#1": {
"interval": 3600 # hour level
},
"mlprimitives.custom.timeseries_preprocessing.rolling_window_sequences#1": {
"target_column": 0,
"window_size": 50
}
}
# with tadGAN
orion = Orion(
'tadgan.json',
parameters
)
anomalies = orion.fit_detect(df)
给出这个错误:
Exception caught fitting MLBlock orion.primitives.tadgan.TadGAN#1
Traceback (most recent call last):
File "/usr/local/lib/python3.7/dist-packages/mlblocks/mlpipeline.py", line 549, in _fit_block
block.fit(**fit_args)
File "/usr/local/lib/python3.7/dist-packages/mlblocks/mlblock.py", line 302, in fit
getattr(self.instance, self.fit_method)(**fit_kwargs)
File "/usr/local/lib/python3.7/dist-packages/orion/primitives/tadgan.py", line 251, in fit
X = X.reshape((-1, self.shape[0], 1))
ValueError: cannot reshape array of size 255550 into shape (100,1)
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-7-27445b4ee358> in <module>()
30 )
31
---> 32 anomalies = orion.fit_detect(df)
5 frames
/usr/local/lib/python3.7/dist-packages/orion/primitives/tadgan.py in fit(self, X, **kwargs)
249 """
250 self._build_tadgan(**kwargs)
--> 251 X = X.reshape((-1, self.shape[0], 1))
252 self._fit(X)
253
ValueError: cannot reshape array of size 255550 into shape (100,1)
但它适用于不同的模型(使用上面定义的参数)
# with LSTM
lstm_orion = Orion(
'lstm_dynamic_threshold.json',
parameters
)
lstm_anomalies = lstm_orion.fit_detect(df)
lstm_anomalies
给出这样的结果(如预期的那样!)
start end severity
0 1404345600 1404694800 0.161157
1 1414706400 1415145600 0.655987
2 1422147600 1422590400 0.503789
如何更改 tadGAN 的窗口大小?