FB-Prophet 在 R 中获取变化点:m$changepoints.t 代表什么?

问题描述 投票:0回答:2

我正在使用 Facebook 的 Prophet 算法进行时间序列中的变化点检测。当我浏览网站上的教程时,我注意到

prophet()
调用的输出中有多个向量引用了变化点。

假设

m
是你的预言家输出对象,那么
m$changepoints
输出一个带有变化日期的向量,而
m$params$delta
输出变化率(我想),如论文中所述:“趋势的生成模型是在 T 点的历史记录中存在 S 变化点,每个变化点都有一个速率 改变 formula”(Taylor & Letham,2018 年。第 40 页)。

但是

m$changepoints.t
到底是什么? 起初,我认为这个向量包含检测到变化点的时间 t 处的原始时间序列的值。但是当我检查
m$changepoints.t
的值时,它的值介于 0 和 1 之间,而我的原始时间序列的值不低于 5.263。

这是代码:

# load in the log number of views to Peyton Manning’s Wikipedia page
peytondf <- read.csv("https://raw.githubusercontent.com/facebook/prophet/ba9a5a2c6e2400206017a5ddfd71f5042da9f65b/examples/example_wp_log_peyton_manning.csv")

# make a prophet object
m <- prophet(peytondf)

# Prepare a dataframe with dates over which to predict new values
future <- make_future_dataframe(m, periods = 30)

# make a forecast over the dates in the future
forecast <- predict(m, future)

让我们比较一下变化点的一些不同输出,以及原始时间序列的汇总统计。

> print(m$params$delta)
              [,1]         [,2]      [,3]      [,4]         [,5]          [,6]       [,7]
[1,] -7.747987e-08 5.963255e-08 0.3511606 0.4575449 3.446425e-09 -3.234277e-05 -0.2446286
           [,8]        [,9]        [,10]         [,11]     [,12]     [,13]       [,14]
[1,] -0.2479764 2.22051e-08 4.905514e-08 -4.845165e-08 0.2993031 0.2125642 0.001508987
            [,15]      [,16]         [,17]         [,18]        [,19]     [,20]      [,21]
[1,] 0.0001771334 -0.8544597 -8.687544e-07 -8.719968e-08 7.831569e-07 0.4638492 0.01226102
            [,22]      [,23]        [,24]         [,25]
[1,] 1.597865e-07 -0.3350588 8.737527e-08 -3.928844e-08

> print(m$changepoints.t) 
 [1] 0.03307459 0.06513669 0.10327371 0.13533581 0.16672292 0.19811002 0.23152211 0.26425920
 [9] 0.29632130 0.33007087 0.36145798 0.39284509 0.42423220 0.45561930 0.48768140 0.51974350
[17] 0.55146811 0.58285521 0.61390483 0.64529193 0.67667904 0.70840364 0.73979075 0.77151536
[25] 0.80290246

> summary(peytondf)
      ds                  y         
 Length:2905        Min.   : 5.263  
 Class :character   1st Qu.: 7.515  
 Mode  :character   Median : 7.998  
                    Mean   : 8.139  
                    3rd Qu.: 8.580  
                    Max.   :12.847 
r time-series facebook-prophet
2个回答
2
投票

默认情况下,Prophet 使用 25 个潜在的变化点,这些变化点在时间序列中均匀分布,但其中一些未使用。 print(m$changepoints.t) 显示所有潜在的变更点。您可以可视化最终使用的变更点

plot(m, forecast) + add_changepoints_to_plot(m)

趋势变点先知


0
投票

如何提取 Prophet() 使用的变更点(如 POSIXct)?当我使用 m$changepoint 时,无论我使用什么时间序列,它总是返回相同的数据。

© www.soinside.com 2019 - 2024. All rights reserved.