【问题标题】:Python Seasonality DetectionPython 季节性检测
【发布时间】:2017-10-28 01:28:11
【问题描述】:

在 Python 中检测信号(时间序列)中的季节性的最佳方法是什么?我想为算法提供信号,输出应该是 1 表示存在季节性,0 表示不存在。

【问题讨论】:

标签: time-series signals detection


【解决方案1】:

希望对一些基本用法有所帮助,但对于复杂的问题,我仍然不建议这样做。我写的一个简单的季节性检测代码:

def check_repetition(arr, limit, index_start, index_end):
    """
    Checks repetition in data so that we can apply de-noising.
    """
    length = index_start

    # length is the length we want to apply the checking
    # check how many periods there are with that kind of length
    for i in range(0, int( len(array)/length)):

        # if the difference in seasons is not smaller than the limit
        condition  = np.array( arr[i:int(i+length)]) - np.array( arr[int( i+length):int( i+2*length)])
        condition  = np.sum([abs(number) for number in condition])

        if condition >= limit :
            # check if the length is still bigger than the limit
            # increase the length to check 
            if length + 1 <= index_end:
                #print( "Checked for length:" + str( length))
                return check_repetition(arr, limit, length + 1, index_end)

            # if not than no more computations needed
            else:
                return 0

        # if it passed the for loop for one cycle of i then return the number of entries per cycle
        if i == int( len(array)/length)-2:
            return(length)

    # if nothing worked
    return 0

这将返回季节性长度。您可以从数组长度/2 到一个小值或相反的季节性开始使用它。还包括一些带有参数限制的噪声检测,它应该限制接受的噪声量。

【讨论】:

    猜你喜欢
    • 2015-05-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-03-13
    • 1970-01-01
    • 2018-05-16
    • 1970-01-01
    • 2016-07-26
    相关资源
    最近更新 更多