1

私は現在、Facebook の Prophet パッケージを使用して、R.

これが私の現在のデータのモックアップです:

ds <- as.Date(c('2016-11-01','2016-11-02','2016-11-03','2016-11-04',
                '2016-11-05','2016-11-06','2016-11-07','2016-11-08',
                '2016-11-09','2016-11-10','2016-11-11','2016-11-12',
                '2016-11-13','2016-11-14','2016-11-15','2016-11-16',
                '2016-11-17','2016-11-18','2016-11-19','2016-11-20',
                '2016-11-21','2016-11-22','2016-11-23','2016-11-24',
                '2016-11-25','2016-11-26','2016-11-27','2016-11-28',
                '2016-11-29','2016-11-30',


                '2016-11-01','2016-11-02','2016-11-03','2016-11-04',
                '2016-11-05','2016-11-06','2016-11-07','2016-11-08',
                '2016-11-09','2016-11-10','2016-11-11','2016-11-12',
                '2016-11-13','2016-11-14','2016-11-15','2016-11-16',
                '2016-11-17','2016-11-18','2016-11-19','2016-11-20',
                '2016-11-21','2016-11-22','2016-11-23','2016-11-24',
                '2016-11-25','2016-11-26','2016-11-27','2016-11-28',
                '2016-11-29','2016-11-30'))
y <- c(15,17,18,19,20,54,67,23,12,34,12,78,34,12,3,45,67,89,12,111,123,112,14,566,345,123,567,56,87,90,
       45,23,12,10,21,34,12,45,12,44,87,45,32,67,1,57,87,99,33,234,456,123,89,333,411,232,455,55,90,21)
y<-as.numeric(y)

some_group<-c("A","A","A","A","A","A","A","A","A","A","A","A","A","A","A",
         "A","A","A","A","A","A","A","A","A","A","A","A","A","A","A",
         "B","B","B","B","B","B","B","B","B","B","B","B","B","B","B",
         "B","B","B","B","B","B","B","B","B","B","B","B","B","B","B")

df <- data.frame(ds,some_group, y)

df を使用すると、次のようになります。

            ds some_group   y
1  2016-11-01     A  15
2  2016-11-02     A  17
3  2016-11-03     A  18
4  2016-11-04     A  19
5  2016-11-05     A  20
6  2016-11-06     A  54
7  2016-11-07     A  67
8  2016-11-08     A  23
9  2016-11-09     A  12
10 2016-11-10     A  34
11 2016-11-11     A  12
12 2016-11-12     A  78
13 2016-11-13     A  34
14 2016-11-14     A  12
15 2016-11-15     A   3
16 2016-11-16     A  45
17 2016-11-17     A  67
18 2016-11-18     A  89
19 2016-11-19     A  12
20 2016-11-20     A 111
21 2016-11-21     A 123
22 2016-11-22     A 112
23 2016-11-23     A  14
24 2016-11-24     A 566
25 2016-11-25     A 345
26 2016-11-26     A 123
27 2016-11-27     A 567
28 2016-11-28     A  56
29 2016-11-29     A  87
30 2016-11-30     A  90
31 2016-11-01     B  45
32 2016-11-02     B  23
33 2016-11-03     B  12
34 2016-11-04     B  10
35 2016-11-05     B  21
36 2016-11-06     B  34
37 2016-11-07     B  12
38 2016-11-08     B  45
39 2016-11-09     B  12
40 2016-11-10     B  44
41 2016-11-11     B  87
42 2016-11-12     B  45
43 2016-11-13     B  32
44 2016-11-14     B  67
45 2016-11-15     B   1
46 2016-11-16     B  57
47 2016-11-17     B  87
48 2016-11-18     B  99
49 2016-11-19     B  33
50 2016-11-20     B 234
51 2016-11-21     B 456
52 2016-11-22     B 123
53 2016-11-23     B  89
54 2016-11-24     B 333
55 2016-11-25     B 411
56 2016-11-26     B 232
57 2016-11-27     B 455
58 2016-11-28     B  55
59 2016-11-29     B  90
60 2016-11-30     B  21

Rでの私の現在の実装は機能します。ただし、カスタム季節性の仕様に関して、プロジェクトのドキュメントページで指定されているように、カスタム季節性を追加できるコードの一部がありません。

これが私の現在の実装です。

df2 <- df %>% 
  group_by(some_group) %>% 
  do(predict(prophet(., 
                     holidays = custom_events,
                     yearly.seasonality = FALSE,
                     weekly.seasonality = FALSE,
                     daily.seasonality = FALSE), # missing custom seasonality
             make_future_dataframe(prophet(.,
                                           holidays = events,
                                           yearly.seasonality = FALSE,
                                           weekly.seasonality = FALSE,
                                           daily.seasonality = FALSE), 
                                   periods = 30*7))) %>%
  select(ds, some_group, yhat)

このパイプ操作にカスタムの季節性を追加するにはどうすればよいですか?

4

0 に答える 0