【问题标题】:How to predict seasonal spikes in time series and ignore spikes which are not seasonal?如何预测时间序列中的季节性峰值并忽略非季节性峰值?
【发布时间】:2019-05-20 11:59:50
【问题描述】:

我刚刚开始进行时间序列预测,并试图找出以下用例的解决方案。 我想检测进入我们系统的非季节性警报。如果传入的警报是季节性的,我想忽略它们。不符合季节性模式的异常值我需要将它们升级到处理模块。

#Creating time series which has spikes every 20th time interval.
alert_once_a_day = [1.0 if i % 20 == 0 else 0.0  for i in range(100)]
#Adding an outlier at 27, which does not fit pattern of spikes at every 20 th interval.
alert_once_a_day[27] =1.0

在上述系列中,我想找出所有以季节性模式发生的警报并忽略它们。

【问题讨论】:

  • 您的意思是“我想检测-季节性警报”吗?即,忽略季节性峰值,寻找异常峰值?
  • 您的警报是二进制 0/1 吗?
  • 另外,alert_once_a_day 数组是否可以作为布尔数组?或者它是否期望是一个十进制值数组?例如,0.5 是可能的值吗?
  • 它将是一个布尔数组。除了 0 和 1 之外,不会有任何其他值。
  • 你知道季节之间的时间吗?或者可以是任何数字吗?

标签: python numpy scipy fft


【解决方案1】:

最简单的答案,使用掩码:

alert_once_a_day = [1.0 if i % 20 == 0 else 0.0  for i in range(100)]

seasonal_alerts = list(alert_once_a_day)
mask = np.array(seasonal_alerts) == 0

#Adding an outlier at 27, which does not fit pattern of spikes at every 20 th interval.
alert_once_a_day[27] =1.0

# assuming your zeros are "non alert" values, the mask will eliminate seasonal peaks:    
true_alerts = np.where(np.array(alert_once_a_day) * mask==1)
true_alerts
>> (array([27], dtype=int64),)

【讨论】:

    猜你喜欢
    • 2016-07-26
    • 2018-06-01
    • 2012-08-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-01-16
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多