You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用TimeEval的subsequence_lof算法时出现维度差99的索引错误

解决TimeEval中subsequence_lof的索引维度不匹配问题

问题根源

报错里的维度差99是因为subsequence_lof基于滑动窗口计算异常分数:假设算法默认窗口大小为100,原始序列长度5040经过处理后,输出的分数序列长度为 5040 - 100 + 1 = 4941,比原始标签序列短99个元素。而TimeEval的指标计算要求分数序列与标签序列长度完全一致,因此触发索引错误。

解决方案

方案1:添加分数后处理器补全长度

TimeEval支持通过score_post_processor参数,用内置的窗口分数映射器补全序列长度,让分数序列和原始数据长度匹配。修改Algorithm定义如下:

from timeeval.postprocessing import window_mean_score_processor

algorithms = [
    Algorithm(
        name="subsequence_lof",
        main=DockerAdapter(
            image_name="registry.gitlab.hpi.de/akita/i/subsequence_lof",
            tag="latest",
            skip_pull=True
        ),
        data_as_file=True,
        training_type=TrainingType.UNSUPERVISED,
        input_dimensionality=InputDimensionality.MULTIVARIATE,
        # 后处理器窗口大小需与subsequence_lof的窗口参数一致
        score_post_processor=window_mean_score_processor(window_size=100)
    ),
]

方案2:显式指定subsequence_lof的窗口参数

如果默认窗口大小不符合需求,可通过param_config指定窗口大小,同时确保后处理器的window_size与之一致:

algorithms = [
    Algorithm(
        name="subsequence_lof",
        main=DockerAdapter(
            image_name="registry.gitlab.hpi.de/akita/i/subsequence_lof",
            tag="latest",
            skip_pull=True
        ),
        param_config=FixedParameters({"window_size": 100, "n_neighbors": 20}),
        data_as_file=True,
        training_type=TrainingType.UNSUPERVISED,
        input_dimensionality=InputDimensionality.MULTIVARIATE,
        score_post_processor=window_mean_score_processor(window_size=100)
    ),
]

方案3:开启自动窗口推断(部分算法支持)

部分基于窗口的算法会在输出中附带窗口大小信息,TimeEval可自动推断并补全序列。尝试开启auto_post_process参数:

algorithms = [
    Algorithm(
        name="subsequence_lof",
        main=DockerAdapter(
            image_name="registry.gitlab.hpi.de/akita/i/subsequence_lof",
            tag="latest",
            skip_pull=True
        ),
        data_as_file=True,
        training_type=TrainingType.UNSUPERVISED,
        input_dimensionality=InputDimensionality.MULTIVARIATE,
        auto_post_process=True
    ),
]

验证方法

修改代码后重新运行,若仍报错,可通过公式 原始序列长度 - 分数序列长度 + 1 计算出算法实际使用的窗口大小,用该值设置后处理器的window_size即可。

内容的提问来源于stack exchange,提问作者Stéphane

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.13 04:01:42