In [1]:
import pandas as pd
import numpy as np

import pyaf.ForecastEngine as autof
import pyaf.Bench.TS_datasets as tsds
import pyaf.Bench.NN3 as tNN3

%matplotlib inline

In [2]:
tester1 = tNN3.cNN_Tester(tsds.load_NN5() , "NN5");
tester1.testSignals('NN5-025')


BENCH_TYPE NN5 OneDataFrameForAllSignals
BENCH_DATA NN5 <pyaf.Bench.TS_datasets.cTimeSeriesDatasetSpec object at 0x7f8876ddf5f8>
TIME :  Day N= 789 H= 2 HEAD= ['1996-03-18T00:00:00.000000000' '1996-03-19T00:00:00.000000000'
 '1996-03-20T00:00:00.000000000' '1996-03-21T00:00:00.000000000'
 '1996-03-22T00:00:00.000000000'] TAIL= ['1998-05-11T00:00:00.000000000' '1998-05-12T00:00:00.000000000'
 '1998-05-13T00:00:00.000000000' '1998-05-14T00:00:00.000000000'
 '1998-05-15T00:00:00.000000000']
SIGNAL :  NN5-025 N= 789 H= 2 HEAD= [  9.467  11.876  17.956  25.071  19.827] TAIL= [ 17.829  15.59   22.676  32.625  32.129]
   NN5-025        Day
0    9.467 1996-03-18
1   11.876 1996-03-19
2   17.956 1996-03-20
3   25.071 1996-03-21
4   19.827 1996-03-22
<class 'pandas.core.frame.DataFrame'>
Int64Index: 789 entries, 0 to 788
Data columns (total 2 columns):
NN5-025    789 non-null float64
Day        789 non-null datetime64[ns]
dtypes: datetime64[ns](1), float64(1)
memory usage: 18.5 KB
None
      Transformation                                              Model  \
0           _NN5-025  _NN5-025_ConstantTrend_residue_Seasonal_DayOfW...   
1           _NN5-025  _NN5-025_ConstantTrend_residue_bestCycle_byL2_...   
2           _NN5-025  _NN5-025_LinearTrend_residue_Seasonal_DayOfWee...   
3           _NN5-025  _NN5-025_LinearTrend_residue_bestCycle_byL2_re...   
4     CumSum_NN5-025  CumSum_NN5-025_LinearTrend_residue_zeroCycle_r...   
5     CumSum_NN5-025  CumSum_NN5-025_LinearTrend_residue_Seasonal_Da...   
6       Diff_NN5-025  Diff_NN5-025_LinearTrend_residue_Seasonal_DayO...   
7           _NN5-025  _NN5-025_ConstantTrend_residue_zeroCycle_resid...   
8           _NN5-025  _NN5-025_ConstantTrend_residue_Seasonal_DayOfM...   
9     CumSum_NN5-025  CumSum_NN5-025_LinearTrend_residue_bestCycle_b...   
10      Diff_NN5-025  Diff_NN5-025_LinearTrend_residue_zeroCycle_res...   
11      Diff_NN5-025  Diff_NN5-025_ConstantTrend_residue_Seasonal_Da...   
12    CumSum_NN5-025  CumSum_NN5-025_PolyTrend_residue_Seasonal_DayO...   
13    CumSum_NN5-025  CumSum_NN5-025_PolyTrend_residue_bestCycle_byL...   
14    CumSum_NN5-025  CumSum_NN5-025_LinearTrend_residue_Seasonal_Da...   
15          _NN5-025  _NN5-025_LinearTrend_residue_Seasonal_DayOfMon...   
16          _NN5-025  _NN5-025_LinearTrend_residue_Seasonal_DayOfWee...   
17          _NN5-025  _NN5-025_LinearTrend_residue_bestCycle_byL2_re...   
18          _NN5-025  _NN5-025_LinearTrend_residue_zeroCycle_residue...   
19      Diff_NN5-025  Diff_NN5-025_LinearTrend_residue_Seasonal_DayO...   
20      Diff_NN5-025  Diff_NN5-025_LinearTrend_residue_bestCycle_byL...   
21      Diff_NN5-025  Diff_NN5-025_PolyTrend_residue_Seasonal_DayOfM...   
22          _NN5-025  _NN5-025_PolyTrend_residue_Seasonal_DayOfWeek_...   
23          _NN5-025  _NN5-025_PolyTrend_residue_bestCycle_byL2_resi...   
24          _NN5-025  _NN5-025_ConstantTrend_residue_Seasonal_DayOfM...   
25          _NN5-025  _NN5-025_ConstantTrend_residue_Seasonal_DayOfW...   
26          _NN5-025  _NN5-025_ConstantTrend_residue_bestCycle_byL2_...   
27      Diff_NN5-025  Diff_NN5-025_ConstantTrend_residue_zeroCycle_r...   
28          _NN5-025  _NN5-025_PolyTrend_residue_Seasonal_DayOfWeek_...   
29          _NN5-025  _NN5-025_PolyTrend_residue_bestCycle_byL2_resi...   
..               ...                                                ...   
98    CumSum_NN5-025  CumSum_NN5-025_ConstantTrend_residue_Seasonal_...   
99   RelDiff_NN5-025  RelDiff_NN5-025_ConstantTrend_residue_zeroCycl...   
100  RelDiff_NN5-025  RelDiff_NN5-025_ConstantTrend_residue_Seasonal...   
101  RelDiff_NN5-025  RelDiff_NN5-025_ConstantTrend_residue_Seasonal...   
102  RelDiff_NN5-025  RelDiff_NN5-025_ConstantTrend_residue_bestCycl...   
103  RelDiff_NN5-025  RelDiff_NN5-025_LinearTrend_residue_zeroCycle_...   
104  RelDiff_NN5-025  RelDiff_NN5-025_PolyTrend_residue_zeroCycle_re...   
105  RelDiff_NN5-025  RelDiff_NN5-025_LinearTrend_residue_Seasonal_D...   
106  RelDiff_NN5-025  RelDiff_NN5-025_LinearTrend_residue_Seasonal_D...   
107  RelDiff_NN5-025  RelDiff_NN5-025_PolyTrend_residue_Seasonal_Day...   
108  RelDiff_NN5-025  RelDiff_NN5-025_PolyTrend_residue_Seasonal_Day...   
109  RelDiff_NN5-025  RelDiff_NN5-025_LinearTrend_residue_bestCycle_...   
110  RelDiff_NN5-025  RelDiff_NN5-025_PolyTrend_residue_bestCycle_by...   
111  RelDiff_NN5-025  RelDiff_NN5-025_ConstantTrend_residue_zeroCycl...   
112  RelDiff_NN5-025  RelDiff_NN5-025_ConstantTrend_residue_Seasonal...   
113  RelDiff_NN5-025  RelDiff_NN5-025_ConstantTrend_residue_Seasonal...   
114  RelDiff_NN5-025  RelDiff_NN5-025_ConstantTrend_residue_bestCycl...   
115  RelDiff_NN5-025  RelDiff_NN5-025_LinearTrend_residue_zeroCycle_...   
116  RelDiff_NN5-025  RelDiff_NN5-025_PolyTrend_residue_zeroCycle_re...   
117  RelDiff_NN5-025  RelDiff_NN5-025_LinearTrend_residue_Seasonal_D...   
118  RelDiff_NN5-025  RelDiff_NN5-025_LinearTrend_residue_Seasonal_D...   
119  RelDiff_NN5-025  RelDiff_NN5-025_PolyTrend_residue_Seasonal_Day...   
120  RelDiff_NN5-025  RelDiff_NN5-025_PolyTrend_residue_Seasonal_Day...   
121  RelDiff_NN5-025  RelDiff_NN5-025_LinearTrend_residue_bestCycle_...   
122  RelDiff_NN5-025  RelDiff_NN5-025_PolyTrend_residue_bestCycle_by...   
123  RelDiff_NN5-025  RelDiff_NN5-025_Lag1Trend_residue_zeroCycle_re...   
124  RelDiff_NN5-025  RelDiff_NN5-025_Lag1Trend_residue_Seasonal_Day...   
125  RelDiff_NN5-025  RelDiff_NN5-025_Lag1Trend_residue_Seasonal_Day...   
126  RelDiff_NN5-025  RelDiff_NN5-025_Lag1Trend_residue_bestCycle_by...   
127   CumSum_NN5-025  CumSum_NN5-025_ConstantTrend_residue_Seasonal_...   

     Complexity  FitCount       FitL2  FitMAPE  ForecastCount  ForecastL2  \
0             4       629    5.022606   0.2931            158    7.573948   
1             8       629    5.022606   0.2931            158    7.573948   
2            20       629    4.970688   0.2912            158    7.018754   
3            24       629    4.970688   0.2912            158    7.018754   
4            48       629    6.877336   0.4130            158    9.032353   
5            52       629    5.392996   0.3005            158    7.934865   
6            52       629    6.928297   0.4320            158    9.924127   
7             0       629    6.658265   0.4231            158    8.818396   
8             4       629    6.573369   0.4200            158    8.887663   
9            56       629    6.933389   0.4190            158    9.106485   
10           48       629    7.084834   0.4570            158    8.909653   
11           36       629    7.585191   0.3767            158    8.656637   
12           52       629   16.576367   0.3930            158    6.834463   
13           56       629   16.576367   0.3930            158    6.834463   
14           52       629    7.306737   0.4443            158    9.713018   
15           20       629    6.532302   0.4203            158    8.419405   
16          217       629    3.937904   0.2449            158    7.645109   
17          221       629    3.937904   0.2449            158    7.645109   
18           16       629    6.617517   0.4235            158    8.359341   
19           52       629    6.773523   0.5122            158    6.873718   
20           56       629    6.773523   0.5122            158    6.873718   
21           52       629    6.848235   0.4138            158    8.432172   
22           20       629    4.944571   0.2855            158    6.882791   
23           24       629    4.944571   0.2855            158    6.882791   
24          201       629    4.071843   0.2656            158    7.493268   
25          201       629    3.909158   0.2447            158    7.411272   
26          205       629    3.909158   0.2447            158    7.411272   
27           32       629    7.500825   0.3890            158    8.231308   
28          217       629    3.925036   0.2443            158    7.392021   
29          221       629    3.925036   0.2443            158    7.392021   
..          ...       ...         ...      ...            ...         ...   
98           36       629  214.830337   3.0047            158   79.982365   
99           32       629   37.519985   2.8167            158   37.732646   
100          36       629   37.452915   2.8096            158   37.732646   
101          36       629   35.865084   2.6568            158   37.732646   
102          40       629   35.865084   2.6568            158   37.732646   
103          48       629   37.105786   2.7749            158   37.732646   
104          48       629   36.903691   2.7539            158   37.732646   
105          52       629   37.044432   2.7679            158   37.732646   
106          52       629   34.855346   2.5555            158   37.732646   
107          52       629   36.823037   2.7457            158   37.732646   
108          52       629   34.463433   2.5122            158   37.732646   
109          56       629   34.855346   2.5555            158   37.732646   
110          56       629   34.463433   2.5122            158   37.732646   
111         229       629   37.687394   2.8325            158   37.732646   
112         233       629   36.185949   2.6678            158   37.732646   
113         233       629   34.796263   2.5524            158   37.732646   
114         237       629   34.796263   2.5524            158   37.732646   
115         245       629   37.193370   2.7841            158   37.732646   
116         245       629   36.889550   2.7537            158   37.732646   
117         249       629   35.931437   2.6423            158   37.732646   
118         249       629   33.895066   2.4603            158   37.732646   
119         249       629   35.828164   2.6313            158   37.732646   
120         249       629   34.091700   2.4806            158   37.732646   
121         253       629   33.895066   2.4603            158   37.732646   
122         253       629   34.091700   2.4806            158   37.732646   
123         261       629   33.909216   2.5161            158   37.732646   
124         265       629   34.957567   2.6181            158   37.732646   
125         265       629   30.142738   2.1049            158   37.732646   
126         269       629   30.142738   2.1049            158   37.732646   
127         233       629   49.146787   2.2931            158   59.424438   

     ForecastMAPE  TestCount     TestL2  TestMAPE  
0          0.4959          2   9.470316    0.2865  
1          0.4959          2   9.470316    0.2865  
2          0.4990          2   7.643239    0.2285  
3          0.4990          2   7.643239    0.2285  
4          0.5000          2  15.985112    0.4936  
5          0.5024          2   9.470316    0.2865  
6          0.5039          2  19.921159    0.6150  
7          0.5103          2  15.450946    0.4771  
8          0.5134          2  15.520670    0.4790  
9          0.5145          2  15.295947    0.4723  
10         0.5148          2  17.419444    0.5379  
11         0.5225          2  14.275721    0.4405  
12         0.5427          2   5.280554    0.1517  
13         0.5427          2   5.280554    0.1517  
14         0.5442          2  15.520670    0.4790  
15         0.5475          2  13.652146    0.4212  
16         0.5501          2   6.442956    0.1750  
17         0.5501          2   6.442956    0.1750  
18         0.5526          2  13.568739    0.4190  
19         0.5553          2   7.626849    0.2278  
20         0.5553          2   7.626849    0.2278  
21         0.5607          2  10.406847    0.3208  
22         0.5639          2   3.812120    0.1013  
23         0.5639          2   3.812120    0.1013  
24         0.5693          2   7.867496    0.1881  
25         0.5784          2   5.615530    0.1454  
26         0.5784          2   5.615530    0.1454  
27         0.5848          2  11.770077    0.3634  
28         0.5848          2   3.539562    0.0819  
29         0.5848          2   3.539562    0.0819  
..            ...        ...        ...       ...  
98         1.9911          2  15.520670    0.4790  
99         2.9014          2  24.696245    0.7628  
100        2.9014          2  24.696245    0.7628  
101        2.9014          2  24.696245    0.7628  
102        2.9014          2  24.696245    0.7628  
103        2.9014          2  24.696245    0.7628  
104        2.9014          2  24.696245    0.7628  
105        2.9014          2  24.696245    0.7628  
106        2.9014          2  24.696245    0.7628  
107        2.9014          2  24.696245    0.7628  
108        2.9014          2  24.696245    0.7628  
109        2.9014          2  24.696245    0.7628  
110        2.9014          2  24.696245    0.7628  
111        2.9014          2  24.696245    0.7628  
112        2.9014          2  24.696245    0.7628  
113        2.9014          2  24.696245    0.7628  
114        2.9014          2  24.696245    0.7628  
115        2.9014          2  24.696245    0.7628  
116        2.9014          2  24.696245    0.7628  
117        2.9014          2  24.696245    0.7628  
118        2.9014          2  24.696245    0.7628  
119        2.9014          2  24.696245    0.7628  
120        2.9014          2  24.696245    0.7628  
121        2.9014          2  24.696245    0.7628  
122        2.9014          2  24.696245    0.7628  
123        2.9014          2  24.696245    0.7628  
124        2.9014          2  24.696245    0.7628  
125        2.9014          2  24.696245    0.7628  
126        2.9014          2  24.696245    0.7628  
127        3.0275          2  33.841962    0.7794  

[128 rows x 12 columns]
   Transformation                                              Model  \
0        _NN5-025  _NN5-025_ConstantTrend_residue_Seasonal_DayOfW...   
1        _NN5-025  _NN5-025_ConstantTrend_residue_bestCycle_byL2_...   
2        _NN5-025  _NN5-025_LinearTrend_residue_Seasonal_DayOfWee...   
3        _NN5-025  _NN5-025_LinearTrend_residue_bestCycle_byL2_re...   
4  CumSum_NN5-025  CumSum_NN5-025_LinearTrend_residue_zeroCycle_r...   

   Complexity  FitCount     FitL2  FitMAPE  ForecastCount  ForecastL2  \
0           4       629  5.022606   0.2931            158    7.573948   
1           8       629  5.022606   0.2931            158    7.573948   
2          20       629  4.970688   0.2912            158    7.018754   
3          24       629  4.970688   0.2912            158    7.018754   
4          48       629  6.877336   0.4130            158    9.032353   

   ForecastMAPE  TestCount     TestL2  TestMAPE  
0        0.4959          2   9.470316    0.2865  
1        0.4959          2   9.470316    0.2865  
2        0.4990          2   7.643239    0.2285  
3        0.4990          2   7.643239    0.2285  
4        0.5000          2  15.985112    0.4936  
2 0     6.25
1    18.41
Name: NN5-025, dtype: float64
2 0    14.380033
1    14.260056
Name: NN5-025_Forecast, dtype: float64
FORECAST_DETAIL_ACTUAL NN5 NN5-025 [  6.25  18.41]
FORECAST_DETAIL_PREDICTED NN5 NN5-025 [ 14.38003333  14.26005618]
BENCHMARK_PERF_DETAIL NN5 NN5-025 789 2 11.402945041656494 ConstantTrend + Seasonal_DayOfWeek + NoAR 2 0.7631 0.2606

In [ ]: