在 keras 中使用 DONUT 算法

数据挖掘 深度学习 数据 异常检测 自动编码器
2022-03-15 05:28:54

我正在尝试运行 Xu 的 DONUT 算法的这个 repo,但是我遇到了一个我不太理解的错误。自述文件说我应该按如下方式加载 raw_data:

timestamp, values, labels = ...
# If there is no label, simply use all zeros.
labels = np.zeros_like(values, dtype=np.int32)

# Complete the timestamp, and obtain the missing point indicators.
timestamp, missing, (values, labels) = \
    complete_timestamp(timestamp, (values, labels))

但是,当我这样做时,我收到此错误:

ValueError: The shape of ``arrays[0]`` does not agree with the shape of `timestamp` ((109577, 11) vs (109577,))

这对我来说没有意义,因为我想不出时间戳是 11 暗数组的原因。当我将值作为时间戳 arg 传递时,我得到“时间戳必须是一维数组”

很困惑,希望有人能解释一下。

以下是代码中的检查:

if len(timestamp.shape) != 1:
    raise ValueError('`timestamp` must be a 1-D array')

has_arrays = arrays is not None
arrays = [np.asarray(array) for array in (arrays or ())]
for i, array in enumerate(arrays):
    if array.shape != timestamp.shape:
        raise ValueError('The shape of ``arrays[{}]`` does not agree with '
                         'the shape of `timestamp` ({} vs {})'.
                         format(i, array.shape, timestamp.shape))

以及回购本身: https ://github.com/haowen-xu/donut

1个回答

你的timestamp样子怎么样?显然维度太多了。

使用 pandas DataFrames 时,您可以传递.index(如果它不是多索引)或只是np.arange(len(<your_data>))作为时间戳传递。