Model Summary

For every forecast model trained with the Silverkite algorithm, you can print the model summary with only a few lines of code. The model summary gives you insight into model performance, parameter significance, etc.

In this example, we will discuss how to utilize the ModelSummary module to output model summary.

First we’ll load a dataset representing log(daily page views) on the Wikipedia page for Peyton Manning. It contains values from 2007-12-10 to 2016-01-20. More dataset info here.

20
21
22
23
24
25
26
27
28
29
30
31
32
33
 import warnings

 warnings.filterwarnings("ignore")

 from greykite.common.data_loader import DataLoader
 from greykite.framework.templates.autogen.forecast_config import ForecastConfig
 from greykite.framework.templates.autogen.forecast_config import MetadataParam
 from greykite.framework.templates.autogen.forecast_config import ModelComponentsParam
 from greykite.framework.templates.model_templates import ModelTemplateEnum
 from greykite.framework.templates.forecaster import Forecaster

 # Loads dataset into pandas DataFrame
 dl = DataLoader()
 df = dl.load_peyton_manning()

Then we create a forecast model with SILVERKITE template. For a simple example of creating a forecast model, see Simple Forecast. For a detailed tuning tutorial, see Tune your first forecast model.

42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
 # Specifies dataset information
 metadata = MetadataParam(
     time_col="ts",  # name of the time column
     value_col="y",  # name of the value column
     freq="D"  # "H" for hourly, "D" for daily, "W" for weekly, etc.
 )

 # Specifies model parameters
 model_components = ModelComponentsParam(
     changepoints={
         "changepoints_dict": {
             "method": "auto",
             "potential_changepoint_n": 25,
             "regularization_strength": 0.5,
             "resample_freq": "7D",
             "no_changepoint_distance_from_end": "365D"}
     },
     uncertainty={
         "uncertainty_dict": "auto",
     },
     custom={
         "fit_algorithm_dict": {
             "fit_algorithm": "linear",
         },
     }
 )

 # Runs the forecast
 forecaster = Forecaster()
 result = forecaster.run_forecast_config(
     df=df,
     config=ForecastConfig(
         model_template=ModelTemplateEnum.SILVERKITE.name,
         forecast_horizon=365,  # forecasts 365 steps ahead
         coverage=0.95,  # 95% prediction intervals
         metadata_param=metadata,
         model_components_param=model_components
     )
 )

Out:

Fitting 3 folds for each of 1 candidates, totalling 3 fits

Creating model summary

Now that we have the output from run_forecast_config, we are able to access the model summary.

88
89
90
 # Initializes the model summary class.
 # ``max_colwidth`` is the maximum length of predictor names that can be displayed.
 summary = result.model[-1].summary(max_colwidth=30)

The above command creates a model summary class and derives extra information that summarizes the model. Generally the summarized information includes the following sections:

  1. Model parameter section: includes basic model parameter information such as number of observations, number of features, model name and etc.

  2. Model residual section: includes the five number summary of training residuals.

  3. Model coefficients section (for regression model): the estimated coefficients and their p-values/confidence intervals. For linear regression, these are the conventional results; for ridge regression, these are calculated from bootstrap 1; for lasso regression, these are calculated by multi-sample-splitting 2.

  4. Model coefficients section (for tree model): the feature significance.

  5. Model significance section (for regression model only): the overall significance of the regression model, including the coefficient of determination, the F-ratio and its p-value, and model AIC/BIC. The results are based on classical statistical inference and may not be reliable for regularized methods (ridge, lasso, etc.).

  6. Warning section: any warnings for the model summary such as high multicollinearity are displayed in this section.

To see the summary, you can either type summary or print(summary).

114
115
 # Prints the summary
 print(summary)

Out:

================================ Model Summary =================================

Number of observations: 2964,   Number of features: 295
Method: Ordinary least squares
Number of nonzero features: 295

Residuals:
         Min           1Q       Median           3Q          Max
      -1.906      -0.2626     -0.04811       0.1786        3.423

                      Pred_col    Estimate Std. Err     t value  Pr(>|t|) sig. code                 95%CI
                     Intercept      0.7654  0.01626       47.08    <2e-16       ***      (0.7335, 0.7973)
       events_Chinese New Year     0.08181   0.1682      0.4864     0.627                (-0.248, 0.4116)
     events_Chinese New Year-1     -0.1791   0.1836     -0.9753     0.330                (-0.5392, 0.181)
     events_Chinese New Year-2      0.0903   0.1473      0.6128     0.540               (-0.1986, 0.3792)
     events_Chinese New Year+1     0.06637   0.1836      0.3615     0.718               (-0.2936, 0.4264)
     events_Chinese New Year+2      0.1457   0.1473       0.989     0.323               (-0.1431, 0.4345)
          events_Christmas Day     -0.5949   0.1808       -3.29     0.001        **    (-0.9494, -0.2403)
        events_Christmas Day-1     -0.3356   0.1788      -1.877     0.061         .    (-0.6862, 0.01501)
        events_Christmas Day-2     -0.1262   0.1759     -0.7177     0.473               (-0.4711, 0.2187)
        events_Christmas Day+1     -0.4613    0.182      -2.535     0.011         *    (-0.8182, -0.1044)
        events_Christmas Day+2     0.08725   0.1813      0.4813     0.630               (-0.2682, 0.4427)
 events_Easter...hern Ireland]     -0.2407   0.1736      -1.387     0.166              (-0.5811, 0.09965)
 events_Easter...rn Ireland]-1      -0.116  0.08679      -1.337     0.181              (-0.2862, 0.05417)
 events_Easter...rn Ireland]-2    -0.06225  0.08805      -0.707     0.480               (-0.2349, 0.1104)
 events_Easter...rn Ireland]+1    -0.09453   0.1736     -0.5447     0.586               (-0.4348, 0.2458)
 events_Easter...rn Ireland]+2  -7.999e-06   0.1719  -4.653e-05     1.000               (-0.3371, 0.3371)
            events_Good Friday     -0.1886   0.1744      -1.082     0.280               (-0.5305, 0.1533)
          events_Good Friday-1     -0.1271   0.1721     -0.7389     0.460               (-0.4646, 0.2103)
          events_Good Friday-2    -0.02644   0.1723     -0.1534     0.878               (-0.3644, 0.3115)
          events_Good Friday+1    -0.06225  0.08805      -0.707     0.480               (-0.2349, 0.1104)
          events_Good Friday+2      -0.116  0.08679      -1.337     0.181              (-0.2862, 0.05417)
       events_Independence Day     0.04463   0.1295      0.3447     0.730               (-0.2093, 0.2985)
     events_Independence Day-1    -0.01802   0.1294     -0.1392     0.889               (-0.2718, 0.2358)
     events_Independence Day-2    -0.07622   0.1291     -0.5904     0.555               (-0.3293, 0.1769)
     events_Independence Day+1    -0.03397   0.1294     -0.2625     0.793               (-0.2877, 0.2197)
     events_Independence Day+2    -0.03063    0.129     -0.2374     0.812               (-0.2836, 0.2223)
              events_Labor Day     -0.4163   0.1271      -3.274     0.001        **     (-0.6656, -0.167)
            events_Labor Day-1     -0.1837   0.1271      -1.445     0.149              (-0.4329, 0.06562)
            events_Labor Day-2    -0.07267   0.1269     -0.5724     0.567               (-0.3216, 0.1763)
            events_Labor Day+1      -0.277   0.1271       -2.18     0.029         *   (-0.5262, -0.02779)
            events_Labor Day+2      -0.235   0.1267      -1.855     0.064         .    (-0.4833, 0.01337)
           events_Memorial Day     -0.4612   0.1796      -2.568     0.010         *    (-0.8132, -0.1091)
         events_Memorial Day-1      -0.301   0.1796      -1.676     0.094         .    (-0.6532, 0.05121)
         events_Memorial Day-2      -0.148   0.1792     -0.8256     0.409               (-0.4994, 0.2034)
         events_Memorial Day+1     -0.1603   0.1797      -0.892     0.372               (-0.5127, 0.1921)
         events_Memorial Day+2      0.1395   0.1796      0.7766     0.437               (-0.2126, 0.4916)
          events_New Years Day     -0.2591   0.1816      -1.427     0.154              (-0.6153, 0.09702)
        events_New Years Day-1    -0.03097   0.1838     -0.1685     0.866               (-0.3913, 0.3294)
        events_New Years Day-2       0.167   0.1832      0.9118     0.362               (-0.1922, 0.5262)
        events_New Years Day+1       0.136   0.1799      0.7562     0.450               (-0.2167, 0.4888)
        events_New Years Day+2      0.2755   0.1765       1.561     0.119              (-0.07063, 0.6215)
                  events_Other     0.02386  0.03079      0.7749     0.438             (-0.03651, 0.08422)
                events_Other-1     0.01416  0.03051      0.4639     0.643             (-0.04567, 0.07398)
                events_Other-2     0.02948  0.03013      0.9783     0.328              (-0.0296, 0.08856)
                events_Other+1     0.01943  0.03087      0.6294     0.529              (-0.0411, 0.07996)
                events_Other+2     0.01132  0.03051      0.3709     0.711              (-0.0485, 0.07114)
           events_Thanksgiving     -0.3773   0.1792      -2.106     0.035         *   (-0.7286, -0.02604)
         events_Thanksgiving-1     -0.5793   0.1789      -3.238     0.001        **    (-0.9301, -0.2284)
         events_Thanksgiving-2     -0.4208   0.1784      -2.358     0.018         *   (-0.7707, -0.07092)
         events_Thanksgiving+1     -0.2711   0.1791      -1.513     0.130              (-0.6223, 0.08022)
         events_Thanksgiving+2     -0.3666   0.1788       -2.05     0.040         *   (-0.7171, -0.01603)
           events_Veterans Day      0.1038   0.1845      0.5625     0.574                (-0.258, 0.4656)
         events_Veterans Day-1   -0.001774   0.1842   -0.009632     0.992                (-0.363, 0.3595)
         events_Veterans Day-2    -0.01661   0.1836    -0.09047     0.928               (-0.3767, 0.3435)
         events_Veterans Day+1     0.09016   0.1842      0.4895     0.625                (-0.271, 0.4514)
         events_Veterans Day+2     0.01071   0.1832     0.05844     0.953                 (-0.3486, 0.37)
                 str_dow_2-Tue     0.01953   0.1026      0.1903     0.849               (-0.1817, 0.2208)
                 str_dow_3-Wed    -0.06307  0.09958     -0.6333     0.527               (-0.2583, 0.1322)
                 str_dow_4-Thu    -0.07208  0.09756     -0.7388     0.460               (-0.2634, 0.1192)
                 str_dow_5-Fri     -0.2195  0.09801       -2.24     0.025         *   (-0.4117, -0.02734)
                 str_dow_6-Sat     -0.1621   0.1034      -1.567     0.117              (-0.3649, 0.04075)
                 str_dow_7-Sun      0.6018   0.1119       5.377  8.19e-08       ***      (0.3824, 0.8212)
                           ct1      -1.636    3.574     -0.4576     0.647                 (-8.643, 5.372)
                is_weekend:ct1     0.08198    3.402      0.0241     0.981                 (-6.589, 6.753)
             str_dow_2-Tue:ct1       5.606     6.92      0.8102     0.418                 (-7.963, 19.18)
             str_dow_3-Wed:ct1       1.899    5.331      0.3562     0.722                 (-8.553, 12.35)
             str_dow_4-Thu:ct1       13.85    5.825       2.377     0.018         *        (2.424, 25.27)
             str_dow_5-Fri:ct1        9.04    5.824       1.552     0.121                  (-2.38, 20.46)
             str_dow_6-Sat:ct1       6.391    5.464        1.17     0.242                  (-4.322, 17.1)
             str_dow_7-Sun:ct1      -6.307    6.256      -1.008     0.313                  (-18.57, 5.96)
             cp0_2008_03_31_00     -0.3919     5.62    -0.06974     0.944                 (-11.41, 10.63)
  is_weekend:cp0_2008_03_31_00         2.4    5.276       0.455     0.649                 (-7.944, 12.74)
 str_dow_2-Tue...2008_03_31_00      -4.786    10.87     -0.4404     0.660                 (-26.09, 16.52)
 str_dow_3-Wed...2008_03_31_00      -2.286    8.349     -0.2737     0.784                 (-18.66, 14.09)
 str_dow_4-Thu...2008_03_31_00       -14.3    9.091      -1.573     0.116                 (-32.12, 3.528)
 str_dow_5-Fri...2008_03_31_00      -9.091    9.074      -1.002     0.317                 (-26.88, 8.703)
 str_dow_6-Sat...2008_03_31_00      -4.695    8.462     -0.5548     0.579                  (-21.29, 11.9)
 str_dow_7-Sun...2008_03_31_00       7.093    9.677       0.733     0.464                 (-11.88, 26.07)
             cp1_2008_07_21_00      -10.17    4.849      -2.096     0.036         *     (-19.67, -0.6577)
  is_weekend:cp1_2008_07_21_00      -4.493    4.422      -1.016     0.310                 (-13.16, 4.178)
 str_dow_2-Tue...2008_07_21_00       -4.24    9.294     -0.4563     0.648                 (-22.46, 13.98)
 str_dow_3-Wed...2008_07_21_00      -3.988    7.104     -0.5614     0.575                 (-17.92, 9.942)
 str_dow_4-Thu...2008_07_21_00      -7.852    7.712      -1.018     0.309                 (-22.97, 7.271)
 str_dow_5-Fri...2008_07_21_00      -4.497    7.667     -0.5866     0.558                 (-19.53, 10.54)
 str_dow_6-Sat...2008_07_21_00      -8.115     7.09      -1.145     0.252                 (-22.02, 5.787)
 str_dow_7-Sun...2008_07_21_00       3.619    8.102      0.4467     0.655                  (-12.27, 19.5)
             cp2_2008_11_10_00        15.7    4.421       3.551  3.90e-04       ***        (7.032, 24.37)
  is_weekend:cp2_2008_11_10_00         4.0    4.042      0.9898     0.322                 (-3.925, 11.93)
 str_dow_2-Tue...2008_11_10_00       3.725    8.549      0.4357     0.663                 (-13.04, 20.49)
 str_dow_3-Wed...2008_11_10_00       7.771     6.51       1.194     0.233                 (-4.993, 20.54)
 str_dow_4-Thu...2008_11_10_00       15.81    7.066       2.237     0.025         *        (1.954, 29.67)
 str_dow_5-Fri...2008_11_10_00         9.4    7.007       1.341     0.180                  (-4.34, 23.14)
 str_dow_6-Sat...2008_11_10_00       10.48    6.476       1.618     0.106                 (-2.222, 23.18)
 str_dow_7-Sun...2008_11_10_00      -6.472    7.412     -0.8732     0.383                 (-21.01, 8.062)
             cp3_2009_03_09_00       5.416    4.241       1.277     0.202                 (-2.901, 13.73)
  is_weekend:cp3_2009_03_09_00     -0.1131    3.845    -0.02942     0.977                 (-7.653, 7.427)
 str_dow_2-Tue...2009_03_09_00        2.75    8.118      0.3388     0.735                 (-13.17, 18.67)
 str_dow_3-Wed...2009_03_09_00    -0.01356    6.167   -0.002199     0.998                 (-12.11, 12.08)
 str_dow_4-Thu...2009_03_09_00      -4.438    6.707     -0.6617     0.508                 (-17.59, 8.714)
 str_dow_5-Fri...2009_03_09_00      -2.245    6.666     -0.3368     0.736                 (-15.31, 10.83)
 str_dow_6-Sat...2009_03_09_00       -1.56    6.158     -0.2532     0.800                 (-13.64, 10.52)
 str_dow_7-Sun...2009_03_09_00       1.446    7.051      0.2051     0.838                 (-12.38, 15.27)
             cp4_2009_06_29_00      -6.584    4.167       -1.58     0.114                 (-14.76, 1.587)
  is_weekend:cp4_2009_06_29_00     -0.8831    3.794     -0.2328     0.816                 (-8.322, 6.556)
 str_dow_2-Tue...2009_06_29_00      -6.813    8.005     -0.8511     0.395                 (-22.51, 8.883)
 str_dow_3-Wed...2009_06_29_00      -6.275    6.072      -1.034     0.301                  (-18.18, 5.63)
 str_dow_4-Thu...2009_06_29_00      -9.365    6.616      -1.415     0.157                 (-22.34, 3.608)
 str_dow_5-Fri...2009_06_29_00      -6.977    6.584       -1.06     0.289                 (-19.89, 5.933)
 str_dow_6-Sat...2009_06_29_00      -4.408    6.081     -0.7248     0.469                 (-16.33, 7.516)
 str_dow_7-Sun...2009_06_29_00       3.523    6.957      0.5064     0.613                 (-10.12, 17.16)
             cp5_2009_10_19_00       1.156    3.834      0.3015     0.763                 (-6.363, 8.674)
  is_weekend:cp5_2009_10_19_00       3.064    3.498      0.8759     0.381                 (-3.795, 9.923)
 str_dow_2-Tue...2009_10_19_00       3.294    7.398      0.4453     0.656                  (-11.21, 17.8)
 str_dow_3-Wed...2009_10_19_00       5.624    5.616       1.001     0.317                 (-5.387, 16.63)
 str_dow_4-Thu...2009_10_19_00       10.18    6.106       1.668     0.095         .       (-1.789, 22.15)
 str_dow_5-Fri...2009_10_19_00       8.767    6.078       1.443     0.149                  (-3.15, 20.68)
 str_dow_6-Sat...2009_10_19_00       4.552    5.606       0.812     0.417                  (-6.44, 15.54)
 str_dow_7-Sun...2009_10_19_00      -1.486    6.413     -0.2317     0.817                 (-14.06, 11.09)
             cp6_2010_02_15_00      -15.29    3.668      -4.169  3.16e-05       ***      (-22.49, -8.099)
  is_weekend:cp6_2010_02_15_00      -5.353    3.319      -1.613     0.107                 (-11.86, 1.155)
 str_dow_2-Tue...2010_02_15_00       3.225    7.004      0.4605     0.645                 (-10.51, 16.96)
 str_dow_3-Wed...2010_02_15_00      -3.023    5.317     -0.5685     0.570                 (-13.45, 7.403)
 str_dow_4-Thu...2010_02_15_00       2.661    5.782      0.4602     0.645                  (-8.677, 14.0)
 str_dow_5-Fri...2010_02_15_00      -1.452    5.761      -0.252     0.801                 (-12.75, 9.845)
 str_dow_6-Sat...2010_02_15_00      -1.011    5.319       -0.19     0.849                 (-11.44, 9.418)
 str_dow_7-Sun...2010_02_15_00      -4.342    6.085     -0.7137     0.475                 (-16.27, 7.588)
             cp7_2010_06_07_00       22.97    3.571       6.431  1.49e-10       ***        (15.96, 29.97)
  is_weekend:cp7_2010_06_07_00       4.747    3.242       1.464     0.143                   (-1.61, 11.1)
 str_dow_2-Tue...2010_06_07_00      -4.712    6.838     -0.6891     0.491                 (-18.12, 8.696)
 str_dow_3-Wed...2010_06_07_00      -0.469    5.192    -0.09032     0.928                 (-10.65, 9.712)
 str_dow_4-Thu...2010_06_07_00      -12.11     5.63      -2.151     0.032         *      (-23.15, -1.069)
 str_dow_5-Fri...2010_06_07_00      -6.247     5.61      -1.113     0.266                 (-17.25, 4.754)
 str_dow_6-Sat...2010_06_07_00      -3.658    5.194     -0.7043     0.481                 (-13.84, 6.527)
 str_dow_7-Sun...2010_06_07_00       8.403    5.938       1.415     0.157                 (-3.241, 20.05)
             cp8_2010_09_27_00      -19.22    3.188      -6.029  1.87e-09       ***      (-25.47, -12.97)
  is_weekend:cp8_2010_09_27_00      -2.221    2.835     -0.7834     0.433                 (-7.779, 3.337)
 str_dow_2-Tue...2010_09_27_00      -1.548    5.978     -0.2589     0.796                 (-13.27, 10.18)
 str_dow_3-Wed...2010_09_27_00       3.387    4.544      0.7455     0.456                  (-5.522, 12.3)
 str_dow_4-Thu...2010_09_27_00       9.637    4.918        1.96     0.050         .    (-0.006118, 19.28)
 str_dow_5-Fri...2010_09_27_00       5.312    4.896       1.085     0.278                 (-4.288, 14.91)
 str_dow_6-Sat...2010_09_27_00       4.171    4.532      0.9203     0.358                 (-4.716, 13.06)
 str_dow_7-Sun...2010_09_27_00      -6.389    5.181      -1.233     0.218                 (-16.55, 3.769)
             cp9_2011_01_24_00       9.753    2.134       4.571  5.06e-06       ***         (5.57, 13.94)
  is_weekend:cp9_2011_01_24_00       1.978    1.841       1.075     0.283                 (-1.632, 5.588)
 str_dow_2-Tue...2011_01_24_00       3.473    3.878      0.8954     0.371                 (-4.132, 11.08)
 str_dow_3-Wed...2011_01_24_00      -2.198    2.943      -0.747     0.455                 (-7.968, 3.572)
 str_dow_4-Thu...2011_01_24_00        -1.9    3.189     -0.5956     0.551                 (-8.154, 4.354)
 str_dow_5-Fri...2011_01_24_00     -0.6465    3.177     -0.2035     0.839                 (-6.877, 5.584)
 str_dow_6-Sat...2011_01_24_00     -0.4921     2.94     -0.1674     0.867                 (-6.257, 5.273)
 str_dow_7-Sun...2011_01_24_00        2.47    3.364      0.7343     0.463                 (-4.126, 9.066)
            cp10_2011_09_05_00       1.309    1.875       0.698     0.485                 (-2.367, 4.985)
 is_weekend:cp10_2011_09_05_00      -2.708     1.61      -1.682     0.093         .      (-5.864, 0.4488)
 str_dow_2-Tue...2011_09_05_00       -3.11    3.385     -0.9188     0.358                 (-9.747, 3.527)
 str_dow_3-Wed...2011_09_05_00        2.35    2.568      0.9154     0.360                 (-2.684, 7.385)
 str_dow_4-Thu...2011_09_05_00      -2.136    2.775     -0.7699     0.441                 (-7.576, 3.304)
 str_dow_5-Fri...2011_09_05_00      -4.116    2.767      -1.488     0.137                 (-9.541, 1.309)
 str_dow_6-Sat...2011_09_05_00      -2.872    2.565       -1.12     0.263                 (-7.903, 2.158)
 str_dow_7-Sun...2011_09_05_00      0.1629    2.933     0.05554     0.956                 (-5.589, 5.915)
            cp11_2012_01_02_00     -0.9717    2.264     -0.4292     0.668                  (-5.41, 3.467)
 is_weekend:cp11_2012_01_02_00       4.318    1.988       2.172     0.030         *       (0.4204, 8.216)
 str_dow_2-Tue...2012_01_02_00       3.124    4.186      0.7464     0.456                 (-5.083, 11.33)
 str_dow_3-Wed...2012_01_02_00      -1.483    3.164     -0.4686     0.639                 (-7.686, 4.721)
 str_dow_4-Thu...2012_01_02_00       3.597    3.429       1.049     0.294                 (-3.126, 10.32)
 str_dow_5-Fri...2012_01_02_00       8.685    3.427       2.534     0.011         *         (1.965, 15.4)
 str_dow_6-Sat...2012_01_02_00       4.588     3.17       1.447     0.148                  (-1.629, 10.8)
 str_dow_7-Sun...2012_01_02_00     -0.2667    3.624     -0.0736     0.941                  (-7.373, 6.84)
            cp12_2012_04_23_00      -5.821    1.289      -4.516  6.57e-06       ***      (-8.349, -3.294)
 is_weekend:cp12_2012_04_23_00      -2.184    1.168      -1.869     0.062         .       (-4.475, 0.107)
 str_dow_2-Tue...2012_04_23_00      -1.986    2.466     -0.8054     0.421                 (-6.821, 2.849)
 str_dow_3-Wed...2012_04_23_00     -0.7837    1.866       -0.42     0.674                 (-4.442, 2.875)
 str_dow_4-Thu...2012_04_23_00      -2.082    2.026      -1.028     0.304                 (-6.054, 1.891)
 str_dow_5-Fri...2012_04_23_00      -5.412    2.021      -2.678     0.007        **      (-9.375, -1.449)
 str_dow_6-Sat...2012_04_23_00      -2.536    1.865       -1.36     0.174                 (-6.193, 1.121)
 str_dow_7-Sun...2012_04_23_00      0.3504    2.134      0.1642     0.870                 (-3.833, 4.534)
            cp13_2013_04_01_00        4.07   0.4333       9.393    <2e-16       ***          (3.22, 4.92)
 is_weekend:cp13_2013_04_01_00      0.2492   0.4097      0.6083     0.543                (-0.5541, 1.053)
 str_dow_2-Tue...2013_04_01_00     0.06176   0.8687     0.07109     0.943                 (-1.642, 1.765)
 str_dow_3-Wed...2013_04_01_00       1.102   0.6584       1.674     0.094         .      (-0.1886, 2.393)
 str_dow_4-Thu...2013_04_01_00      0.5137   0.7153      0.7182     0.473                (-0.8889, 1.916)
 str_dow_5-Fri...2013_04_01_00       0.631   0.7105      0.8881     0.375                (-0.7622, 2.024)
 str_dow_6-Sat...2013_04_01_00      0.6026   0.6553      0.9196     0.358                (-0.6823, 1.888)
 str_dow_7-Sun...2013_04_01_00     -0.3528   0.7512     -0.4697     0.639                  (-1.826, 1.12)
            cp14_2013_11_11_00      -2.269   0.2403       -9.44    <2e-16       ***       (-2.74, -1.797)
 is_weekend:cp14_2013_11_11_00      0.1677   0.2287      0.7334     0.463               (-0.2807, 0.6161)
 str_dow_2-Tue...2013_11_11_00     0.01125   0.4823     0.02333     0.981                (-0.9345, 0.957)
 str_dow_3-Wed...2013_11_11_00      -0.443   0.3658      -1.211     0.226                 (-1.16, 0.2742)
 str_dow_4-Thu...2013_11_11_00     -0.0236   0.3976    -0.05936     0.953                (-0.8032, 0.756)
 str_dow_5-Fri...2013_11_11_00   -0.004941   0.3951    -0.01251     0.990               (-0.7796, 0.7697)
 str_dow_6-Sat...2013_11_11_00      -0.258   0.3643     -0.7081     0.479               (-0.9723, 0.4564)
 str_dow_7-Sun...2013_11_11_00      0.4253   0.4179       1.018     0.309                (-0.3941, 1.245)
           ct1:sin1_tow_weekly       3.983    3.362       1.185     0.236                 (-2.609, 10.57)
           ct1:cos1_tow_weekly      -28.56     6.38      -4.477  7.88e-06       ***      (-41.07, -16.05)
           ct1:sin2_tow_weekly       5.414    4.103        1.32     0.187                 (-2.631, 13.46)
           ct1:cos2_tow_weekly      -12.86    5.595      -2.298     0.022         *      (-23.83, -1.888)
 cp0_2008_03_3...n1_tow_weekly      -4.335    5.247     -0.8262     0.409                 (-14.62, 5.953)
 cp0_2008_03_3...s1_tow_weekly       27.56    10.02        2.75     0.006        **        (7.912, 47.21)
 cp0_2008_03_3...n2_tow_weekly      -4.008    6.381     -0.6281     0.530                 (-16.52, 8.504)
 cp0_2008_03_3...s2_tow_weekly       10.28    8.797       1.168     0.243                 (-6.973, 27.53)
 cp1_2008_07_2...n1_tow_weekly      -1.455     4.44     -0.3277     0.743                 (-10.16, 7.251)
 cp1_2008_07_2...s1_tow_weekly       15.26    8.564       1.782     0.075         .       (-1.535, 32.05)
 cp1_2008_07_2...n2_tow_weekly      -3.121    5.383     -0.5798     0.562                 (-13.68, 7.434)
 cp1_2008_07_2...s2_tow_weekly       9.953    7.533       1.321     0.187                 (-4.818, 24.72)
 cp2_2008_11_1...n1_tow_weekly       4.548    4.063       1.119     0.263                 (-3.419, 12.52)
 cp2_2008_11_1...s1_tow_weekly      -27.75    7.853      -3.534  4.16e-04       ***      (-43.15, -12.35)
 cp2_2008_11_1...n2_tow_weekly       3.515    4.927      0.7135     0.476                 (-6.145, 13.18)
 cp2_2008_11_1...s2_tow_weekly      -12.83    6.916      -1.856     0.064         .       (-26.4, 0.7269)
 cp3_2009_03_0...n1_tow_weekly       1.191    3.856       0.309     0.757                 (-6.369, 8.752)
 cp3_2009_03_0...s1_tow_weekly       10.07    7.469       1.349     0.178                 (-4.573, 24.72)
 cp3_2009_03_0...n2_tow_weekly        1.57    4.668      0.3362     0.737                 (-7.583, 10.72)
 cp3_2009_03_0...s2_tow_weekly       3.408     6.57      0.5187     0.604                 (-9.475, 16.29)
 cp4_2009_06_2...n1_tow_weekly      -5.231    3.801      -1.376     0.169                 (-12.68, 2.223)
 cp4_2009_06_2...s1_tow_weekly       20.75    7.369       2.816     0.005        **         (6.299, 35.2)
 cp4_2009_06_2...n2_tow_weekly      -3.414    4.602     -0.7419     0.458                 (-12.44, 5.609)
 cp4_2009_06_2...s2_tow_weekly       12.93     6.48       1.995     0.046         *       (0.2207, 25.63)
 cp5_2009_10_1...n1_tow_weekly       3.153    3.512      0.8977     0.369                 (-3.734, 10.04)
 cp5_2009_10_1...s1_tow_weekly      -24.87    6.802      -3.656  2.61e-04       ***      (-38.21, -11.53)
 cp5_2009_10_1...n2_tow_weekly       1.968    4.248      0.4631     0.643                  (-6.363, 10.3)
 cp5_2009_10_1...s2_tow_weekly      -14.11     5.98       -2.36     0.018         *      (-25.84, -2.384)
 cp6_2010_02_1...n1_tow_weekly       3.322    3.332      0.9971     0.319                 (-3.211, 9.856)
 cp6_2010_02_1...s1_tow_weekly      -6.084    6.453     -0.9428     0.346                 (-18.74, 6.569)
 cp6_2010_02_1...n2_tow_weekly       2.968    4.024      0.7377     0.461                 (-4.922, 10.86)
 cp6_2010_02_1...s2_tow_weekly      -3.175    5.661     -0.5608     0.575                 (-14.27, 7.925)
 cp7_2010_06_0...n1_tow_weekly      -4.584    3.254      -1.409     0.159                 (-10.96, 1.795)
 cp7_2010_06_0...s1_tow_weekly       32.72    6.295       5.198  2.16e-07       ***        (20.38, 45.07)
 cp7_2010_06_0...n2_tow_weekly      -4.538    3.932      -1.154     0.249                 (-12.25, 3.172)
 cp7_2010_06_0...s2_tow_weekly       17.83    5.535       3.222     0.001        **        (6.978, 28.69)
 cp8_2010_09_2...n1_tow_weekly       2.894    2.844       1.018     0.309                  (-2.682, 8.47)
 cp8_2010_09_2...s1_tow_weekly      -27.99    5.499       -5.09  3.82e-07       ***      (-38.77, -17.21)
 cp8_2010_09_2...n2_tow_weekly       1.244     3.44      0.3617     0.718                  (-5.501, 7.99)
 cp8_2010_09_2...s2_tow_weekly      -15.16    4.848      -3.128     0.002        **      (-24.67, -5.657)
 cp9_2011_01_2...n1_tow_weekly     -0.3471    1.845     -0.1881     0.851                 (-3.965, 3.271)
 cp9_2011_01_2...s1_tow_weekly       8.601    3.572       2.408     0.016         *         (1.597, 15.6)
 cp9_2011_01_2...n2_tow_weekly       1.767     2.23      0.7925     0.428                 (-2.605, 6.139)
 cp9_2011_01_2...s2_tow_weekly        4.87    3.148       1.547     0.122                 (-1.303, 11.04)
 cp10_2011_09_...n1_tow_weekly        2.12    1.613       1.315     0.189                 (-1.042, 5.283)
 cp10_2011_09_...s1_tow_weekly       8.213    3.121       2.631     0.009        **        (2.092, 14.33)
 cp10_2011_09_...n2_tow_weekly       -3.21    1.948      -1.648     0.100         .       (-7.03, 0.6104)
 cp10_2011_09_...s2_tow_weekly       4.697     2.75       1.708     0.088         .      (-0.6954, 10.09)
 cp11_2012_01_...n1_tow_weekly      -2.421    1.995      -1.213     0.225                 (-6.333, 1.491)
 cp11_2012_01_...s1_tow_weekly      -14.98    3.858      -3.882  1.06e-04       ***      (-22.54, -7.412)
 cp11_2012_01_...n2_tow_weekly       5.465    2.405       2.273     0.023         *       (0.7503, 10.18)
 cp11_2012_01_...s2_tow_weekly      -7.507    3.389      -2.215     0.027         *     (-14.15, -0.8622)
 cp12_2012_04_...n1_tow_weekly       1.058    1.173      0.9019     0.367                 (-1.243, 3.359)
 cp12_2012_04_...s1_tow_weekly       7.236    2.271       3.187     0.001        **        (2.784, 11.69)
 cp12_2012_04_...n2_tow_weekly      -2.508    1.415      -1.773     0.076         .      (-5.282, 0.2659)
 cp12_2012_04_...s2_tow_weekly       3.145    1.994       1.577     0.115                (-0.7644, 7.055)
 cp13_2013_04_...n1_tow_weekly      0.7735   0.4106       1.884     0.060         .     (-0.03169, 1.579)
 cp13_2013_04_...s1_tow_weekly      0.3269   0.7963      0.4106     0.681                 (-1.234, 1.888)
 cp13_2013_04_...n2_tow_weekly      0.5246   0.4984       1.053     0.293                (-0.4527, 1.502)
 cp13_2013_04_...s2_tow_weekly      0.7629   0.7023       1.086     0.277                 (-0.6141, 2.14)
 cp14_2013_11_...n1_tow_weekly      0.1184   0.2284      0.5183     0.604               (-0.3295, 0.5663)
 cp14_2013_11_...s1_tow_weekly     -0.4426   0.4424        -1.0     0.317                 (-1.31, 0.4248)
 cp14_2013_11_...n2_tow_weekly      0.2245   0.2781      0.8072     0.420               (-0.3208, 0.7698)
 cp14_2013_11_...s2_tow_weekly     -0.4055   0.3912      -1.037     0.300                (-1.173, 0.3615)
               sin1_tow_weekly      0.2315   0.1094       2.117     0.034         *       (0.0171, 0.446)
               cos1_tow_weekly       1.079   0.1402       7.694  1.97e-14       ***       (0.8038, 1.354)
               sin2_tow_weekly     0.01042   0.1097     0.09501     0.924               (-0.2047, 0.2255)
               cos2_tow_weekly      0.6487   0.1394       4.652  3.44e-06       ***      (0.3753, 0.9221)
               sin3_tow_weekly      0.2872  0.07488       3.835  1.28e-04       ***       (0.1404, 0.434)
               cos3_tow_weekly      0.3762   0.1399       2.689     0.007        **      (0.1019, 0.6505)
               sin4_tow_weekly      0.4782  0.07392        6.47  1.16e-10       ***      (0.3333, 0.6232)
            sin4_toq_quarterly   -0.002727  0.02556     -0.1067     0.915              (-0.05285, 0.0474)
            cos4_toq_quarterly    -0.07909  0.02633      -3.003     0.003        **   (-0.1307, -0.02746)
            sin5_toq_quarterly    -0.07694  0.02617       -2.94     0.003        **   (-0.1283, -0.02563)
            cos5_toq_quarterly     0.03685    0.026       1.418     0.156             (-0.01412, 0.08783)
               sin1_ct1_yearly     -0.2078  0.03571       -5.82  6.55e-09       ***    (-0.2779, -0.1378)
               cos1_ct1_yearly        1.49  0.03571       41.71    <2e-16       ***          (1.42, 1.56)
               sin2_ct1_yearly      0.1156  0.02814       4.107  4.13e-05       ***     (0.06038, 0.1707)
               cos2_ct1_yearly     -0.1821  0.02749      -6.624  4.19e-11       ***     (-0.236, -0.1282)
               sin3_ct1_yearly      0.5113  0.02808       18.21    <2e-16       ***      (0.4563, 0.5664)
               cos3_ct1_yearly    -0.09124  0.02657      -3.434  6.04e-04       ***   (-0.1433, -0.03914)
               sin4_ct1_yearly    0.004561  0.02764       0.165     0.869             (-0.04963, 0.05875)
               cos4_ct1_yearly     -0.2158  0.02514      -8.586    <2e-16       ***    (-0.2651, -0.1666)
               sin5_ct1_yearly     -0.1972  0.02768      -7.124  1.33e-12       ***    (-0.2515, -0.1429)
               cos5_ct1_yearly    -0.03366  0.02516      -1.338     0.181             (-0.08301, 0.01568)
               sin6_ct1_yearly     -0.2449  0.02747      -8.915    <2e-16       ***     (-0.2987, -0.191)
               cos6_ct1_yearly    -0.05681  0.02614      -2.173     0.030         *  (-0.1081, -0.005541)
               sin7_ct1_yearly     -0.1065  0.02681      -3.973  7.28e-05       ***   (-0.1591, -0.05394)
               cos7_ct1_yearly      0.0886  0.02583        3.43  6.13e-04       ***     (0.03794, 0.1392)
               sin8_ct1_yearly     0.06883  0.02612       2.635     0.008        **      (0.0176, 0.1201)
               cos8_ct1_yearly       0.218  0.02735        7.97  2.30e-15       ***      (0.1644, 0.2716)
               sin9_ct1_yearly    0.008079  0.02618      0.3086     0.758             (-0.04326, 0.05942)
               cos9_ct1_yearly    -0.06029   0.0276      -2.184     0.029         *  (-0.1144, -0.006173)
              sin10_ct1_yearly     -0.1497  0.02627      -5.697  1.34e-08       ***   (-0.2012, -0.09815)
              cos10_ct1_yearly     -0.1351  0.02642      -5.113  3.38e-07       ***   (-0.1869, -0.08329)
              sin11_ct1_yearly    -0.03894   0.0259      -1.503     0.133             (-0.08972, 0.01185)
              cos11_ct1_yearly    -0.03253   0.0266      -1.223     0.221             (-0.08469, 0.01963)
              sin12_ct1_yearly    -0.03764  0.02652      -1.419     0.156             (-0.08964, 0.01436)
              cos12_ct1_yearly     0.02213  0.02664      0.8307     0.406              (-0.0301, 0.07436)
              sin13_ct1_yearly    -0.01893   0.0254     -0.7456     0.456             (-0.06873, 0.03086)
              cos13_ct1_yearly     0.09717   0.0272       3.572  3.60e-04       ***     (0.04383, 0.1505)
              sin14_ct1_yearly     0.07481    0.026       2.877     0.004        **     (0.02383, 0.1258)
              cos14_ct1_yearly    -0.03538   0.0271      -1.305     0.192             (-0.08852, 0.01776)
              sin15_ct1_yearly     0.04844  0.02637       1.837     0.066         .   (-0.003268, 0.1002)
              cos15_ct1_yearly    -0.06051  0.02631      -2.299     0.022         *  (-0.1121, -0.008909)
Signif. Code: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Multiple R-squared: 0.7215,   Adjusted R-squared: 0.7008
F-statistic: 34.856 on 205 and 2757 DF,   p-value: 1.110e-16
Model AIC: 19344.0,   model BIC: 20579.0

WARNING: the condition number is large, 3.41e+19. This might indicate that there are strong multicollinearity or other numerical problems.

The model summary provides useful insights:

  1. We can check the sig. code column to see which features are not significant. For example, the “Independence Day” events are not significant, therefore we could consider removing them from the model.

  2. We can check the effect of each feature by examing the confidence interval. For example, the Christmas day has a negative effect of -0.57, with a confidence interval of -0.93 to -0.22. The changepoint at 2010-02-15 changes the slope by -2.52, with a confidence interval of -3.60 to -1.44.

For linear regression, the results are the same as the regular regression summary in R (the lm function). The usual considerations apply when interpreting the results:

  1. High feature correlation can increase the coefficient variance. This is common in forecasting problems, so we recommend regularized models.

  2. There is no standard way to calculate confidence intervals and p-values for regularized linear models (ridge, lasso, elastic_net). We follow the approach in 1 for ridge inference and 2 for lasso inference. The ideas are to use bootstrap and sample-splitting, respectively.

    • For ridge regression, the confidence intervals and p-values are based on biased estimators. This is a remedy for multicollinearity to produce better forecast, but could lower the true effect of the features.

    • For lasso regression, the confidence intervals and p-values are based on a multi-sample-split procedure. While this approach of generating CIs is optimized for accuracy, they are calculated independently of the coefficient estimates and are not guaranteed to overlap with the estimates. It’s worth noting that the probability of a coefficient being nonzero is also reported in the column Prob_nonzero. This probability can be used to interpret the significance of the corresponding feature.

Moreover, if you would like to explore the numbers behind the printed summary, they are stored in the info_dict attribute, which is a python dictionary.

151
152
 # Prints the keys of the ``info_dict`` dictionary.
 print(summary.info_dict.keys())

Out:

dict_keys(['x', 'y', 'beta', 'ml_model', 'fit_algorithm', 'pred_cols', 'degenerate_index', 'n_sample', 'n_feature', 'nonzero_index', 'n_feature_nonzero', 'y_pred', 'y_mean', 'residual', 'residual_summary', 'model', 'x_nz', 'condition_number', 'xtwx_alphai_inv', 'reg_df', 'df_sse', 'df_ssr', 'df_sst', 'sse', 'mse', 'ssr', 'msr', 'sst', 'mst', 'beta_var_cov', 'coef_summary_df', 'significance_code_legend', 'f_value', 'f_p_value', 'r2', 'r2_adj', 'aic', 'bic', 'model_type'])
156
157
 # The above coefficient summary can be accessed as a pandas Dataframe.
 print(summary.info_dict["coef_summary_df"])

Out:

                                              Pred_col  Estimate  Std. Err    t value  Pr(>|t|) sig. code                                         95%CI
0                                            Intercept  0.765411  0.016258  47.079155  0.000000       ***      (0.7335317623493074, 0.7972897527104521)
1    C(Q('events_Chinese New Year'), levels=['', 'e...  0.081810  0.168197   0.486393  0.626727               (-0.24799503026969638, 0.411614931340316)
2    C(Q('events_Chinese New Year_minus_1'), levels... -0.179094  0.183635  -0.975269  0.329512              (-0.5391702889218035, 0.18098279639307374)
3    C(Q('events_Chinese New Year_minus_2'), levels...  0.090297  0.147350   0.612804  0.540056              (-0.19863068851262217, 0.3792240680895856)
4    C(Q('events_Chinese New Year_plus_1'), levels=...  0.066370  0.183603   0.361486  0.717764             (-0.29364322940090026, 0.42638316275703836)
..                                                 ...       ...       ...        ...       ...       ...                                           ...
290                                   cos13_ct1_yearly  0.097174  0.027202   3.572256  0.000360       ***    (0.04383473321761079, 0.15051281207569983)
291                                   sin14_ct1_yearly  0.074806  0.025997   2.877416  0.004040        **   (0.023829058802337356, 0.12578203627048765)
292                                   cos14_ct1_yearly -0.035378  0.027101  -1.305410  0.191862             (-0.08851837918130084, 0.01776241781718719)
293                                   sin15_ct1_yearly  0.048443  0.026372   1.836923  0.066329         .  (-0.003267542344827748, 0.10015435435758334)
294                                   cos15_ct1_yearly -0.060506  0.026314  -2.299410  0.021556         *  (-0.1121024347541224, -0.008909419192585429)

[295 rows x 7 columns]

Selected features in a category

You may have noticed that there are too many features in the forecast model. It’s not easy to read all of them in the coefficient summary table. The model summary class is able to filter the categories of these features. This is done by the get_coef_summary function.

A few filters are available, including:

  • is_intercept: intercept term.

  • is_time_feature: features defined in build_time_features_df.

  • is_event: holidays and events.

  • is_trend: trend features.

  • is_seasonality: seasonality features.

  • is_lag: autoregressive features.

  • is_regressor: extra regressors provided by user.

  • is_interaction: interaction terms.

All filters set to True will be joined with the logical operator or, while all filters set to False will be joined with the logical operator and. Simply speaking, set what you want to see to True and what you don’t want to see to False.

By default, is_interaction is set to True, this means as long as one feature in an interaction term belongs to a category set to True, the interaction term is included in the output. However, if one feature in an interaction term belongs to a category set to False, the interaction is excluded from the output. To hide interaction terms, set is_interaction to False.

191
192
193
194
195
196
 # Displays intercept, trend features but not seasonality features.
 summary.get_coef_summary(
     is_intercept=True,
     is_trend=True,
     is_seasonality=False
 )

Out:

           Pred_col   Estimate Std. Err    t value  Pr(>|t|) sig. code               95%CI
          Intercept     0.7654  0.01626      47.08    <2e-16       ***    (0.7335, 0.7973)
                ct1     -1.636    3.574    -0.4576     0.647               (-8.643, 5.372)
     is_weekend:ct1    0.08198    3.402     0.0241     0.981               (-6.589, 6.753)
  str_dow_2-Tue:ct1      5.606     6.92     0.8102     0.418               (-7.963, 19.18)
  str_dow_3-Wed:ct1      1.899    5.331     0.3562     0.722               (-8.553, 12.35)
  str_dow_4-Thu:ct1      13.85    5.825      2.377     0.018         *      (2.424, 25.27)
  str_dow_5-Fri:ct1       9.04    5.824      1.552     0.121                (-2.38, 20.46)
  str_dow_6-Sat:ct1      6.391    5.464       1.17     0.242                (-4.322, 17.1)
  str_dow_7-Sun:ct1     -6.307    6.256     -1.008     0.313                (-18.57, 5.96)
  cp0_2008_03_31_00    -0.3919     5.62   -0.06974     0.944               (-11.41, 10.63)
is_weeke...03_31_00        2.4    5.276      0.455     0.649               (-7.944, 12.74)
str_dow_...03_31_00     -4.786    10.87    -0.4404     0.660               (-26.09, 16.52)
str_dow_...03_31_00     -2.286    8.349    -0.2737     0.784               (-18.66, 14.09)
str_dow_...03_31_00      -14.3    9.091     -1.573     0.116               (-32.12, 3.528)
str_dow_...03_31_00     -9.091    9.074     -1.002     0.317               (-26.88, 8.703)
str_dow_...03_31_00     -4.695    8.462    -0.5548     0.579                (-21.29, 11.9)
str_dow_...03_31_00      7.093    9.677      0.733     0.464               (-11.88, 26.07)
  cp1_2008_07_21_00     -10.17    4.849     -2.096     0.036         *   (-19.67, -0.6577)
is_weeke...07_21_00     -4.493    4.422     -1.016     0.310               (-13.16, 4.178)
str_dow_...07_21_00      -4.24    9.294    -0.4563     0.648               (-22.46, 13.98)
str_dow_...07_21_00     -3.988    7.104    -0.5614     0.575               (-17.92, 9.942)
str_dow_...07_21_00     -7.852    7.712     -1.018     0.309               (-22.97, 7.271)
str_dow_...07_21_00     -4.497    7.667    -0.5866     0.558               (-19.53, 10.54)
str_dow_...07_21_00     -8.115     7.09     -1.145     0.252               (-22.02, 5.787)
str_dow_...07_21_00      3.619    8.102     0.4467     0.655                (-12.27, 19.5)
  cp2_2008_11_10_00       15.7    4.421      3.551  3.90e-04       ***      (7.032, 24.37)
is_weeke...11_10_00        4.0    4.042     0.9898     0.322               (-3.925, 11.93)
str_dow_...11_10_00      3.725    8.549     0.4357     0.663               (-13.04, 20.49)
str_dow_...11_10_00      7.771     6.51      1.194     0.233               (-4.993, 20.54)
str_dow_...11_10_00      15.81    7.066      2.237     0.025         *      (1.954, 29.67)
str_dow_...11_10_00        9.4    7.007      1.341     0.180                (-4.34, 23.14)
str_dow_...11_10_00      10.48    6.476      1.618     0.106               (-2.222, 23.18)
str_dow_...11_10_00     -6.472    7.412    -0.8732     0.383               (-21.01, 8.062)
  cp3_2009_03_09_00      5.416    4.241      1.277     0.202               (-2.901, 13.73)
is_weeke...03_09_00    -0.1131    3.845   -0.02942     0.977               (-7.653, 7.427)
str_dow_...03_09_00       2.75    8.118     0.3388     0.735               (-13.17, 18.67)
str_dow_...03_09_00   -0.01356    6.167  -0.002199     0.998               (-12.11, 12.08)
str_dow_...03_09_00     -4.438    6.707    -0.6617     0.508               (-17.59, 8.714)
str_dow_...03_09_00     -2.245    6.666    -0.3368     0.736               (-15.31, 10.83)
str_dow_...03_09_00      -1.56    6.158    -0.2532     0.800               (-13.64, 10.52)
str_dow_...03_09_00      1.446    7.051     0.2051     0.838               (-12.38, 15.27)
  cp4_2009_06_29_00     -6.584    4.167      -1.58     0.114               (-14.76, 1.587)
is_weeke...06_29_00    -0.8831    3.794    -0.2328     0.816               (-8.322, 6.556)
str_dow_...06_29_00     -6.813    8.005    -0.8511     0.395               (-22.51, 8.883)
str_dow_...06_29_00     -6.275    6.072     -1.034     0.301                (-18.18, 5.63)
str_dow_...06_29_00     -9.365    6.616     -1.415     0.157               (-22.34, 3.608)
str_dow_...06_29_00     -6.977    6.584      -1.06     0.289               (-19.89, 5.933)
str_dow_...06_29_00     -4.408    6.081    -0.7248     0.469               (-16.33, 7.516)
str_dow_...06_29_00      3.523    6.957     0.5064     0.613               (-10.12, 17.16)
  cp5_2009_10_19_00      1.156    3.834     0.3015     0.763               (-6.363, 8.674)
is_weeke...10_19_00      3.064    3.498     0.8759     0.381               (-3.795, 9.923)
str_dow_...10_19_00      3.294    7.398     0.4453     0.656                (-11.21, 17.8)
str_dow_...10_19_00      5.624    5.616      1.001     0.317               (-5.387, 16.63)
str_dow_...10_19_00      10.18    6.106      1.668     0.095         .     (-1.789, 22.15)
str_dow_...10_19_00      8.767    6.078      1.443     0.149                (-3.15, 20.68)
str_dow_...10_19_00      4.552    5.606      0.812     0.417                (-6.44, 15.54)
str_dow_...10_19_00     -1.486    6.413    -0.2317     0.817               (-14.06, 11.09)
  cp6_2010_02_15_00     -15.29    3.668     -4.169  3.16e-05       ***    (-22.49, -8.099)
is_weeke...02_15_00     -5.353    3.319     -1.613     0.107               (-11.86, 1.155)
str_dow_...02_15_00      3.225    7.004     0.4605     0.645               (-10.51, 16.96)
str_dow_...02_15_00     -3.023    5.317    -0.5685     0.570               (-13.45, 7.403)
str_dow_...02_15_00      2.661    5.782     0.4602     0.645                (-8.677, 14.0)
str_dow_...02_15_00     -1.452    5.761     -0.252     0.801               (-12.75, 9.845)
str_dow_...02_15_00     -1.011    5.319      -0.19     0.849               (-11.44, 9.418)
str_dow_...02_15_00     -4.342    6.085    -0.7137     0.475               (-16.27, 7.588)
  cp7_2010_06_07_00      22.97    3.571      6.431  1.49e-10       ***      (15.96, 29.97)
is_weeke...06_07_00      4.747    3.242      1.464     0.143                 (-1.61, 11.1)
str_dow_...06_07_00     -4.712    6.838    -0.6891     0.491               (-18.12, 8.696)
str_dow_...06_07_00     -0.469    5.192   -0.09032     0.928               (-10.65, 9.712)
str_dow_...06_07_00     -12.11     5.63     -2.151     0.032         *    (-23.15, -1.069)
str_dow_...06_07_00     -6.247     5.61     -1.113     0.266               (-17.25, 4.754)
str_dow_...06_07_00     -3.658    5.194    -0.7043     0.481               (-13.84, 6.527)
str_dow_...06_07_00      8.403    5.938      1.415     0.157               (-3.241, 20.05)
  cp8_2010_09_27_00     -19.22    3.188     -6.029  1.87e-09       ***    (-25.47, -12.97)
is_weeke...09_27_00     -2.221    2.835    -0.7834     0.433               (-7.779, 3.337)
str_dow_...09_27_00     -1.548    5.978    -0.2589     0.796               (-13.27, 10.18)
str_dow_...09_27_00      3.387    4.544     0.7455     0.456                (-5.522, 12.3)
str_dow_...09_27_00      9.637    4.918       1.96     0.050         .  (-0.006118, 19.28)
str_dow_...09_27_00      5.312    4.896      1.085     0.278               (-4.288, 14.91)
str_dow_...09_27_00      4.171    4.532     0.9203     0.358               (-4.716, 13.06)
str_dow_...09_27_00     -6.389    5.181     -1.233     0.218               (-16.55, 3.769)
  cp9_2011_01_24_00      9.753    2.134      4.571  5.06e-06       ***       (5.57, 13.94)
is_weeke...01_24_00      1.978    1.841      1.075     0.283               (-1.632, 5.588)
str_dow_...01_24_00      3.473    3.878     0.8954     0.371               (-4.132, 11.08)
str_dow_...01_24_00     -2.198    2.943     -0.747     0.455               (-7.968, 3.572)
str_dow_...01_24_00       -1.9    3.189    -0.5956     0.551               (-8.154, 4.354)
str_dow_...01_24_00    -0.6465    3.177    -0.2035     0.839               (-6.877, 5.584)
str_dow_...01_24_00    -0.4921     2.94    -0.1674     0.867               (-6.257, 5.273)
str_dow_...01_24_00       2.47    3.364     0.7343     0.463               (-4.126, 9.066)
 cp10_2011_09_05_00      1.309    1.875      0.698     0.485               (-2.367, 4.985)
is_weeke...09_05_00     -2.708     1.61     -1.682     0.093         .    (-5.864, 0.4488)
str_dow_...09_05_00      -3.11    3.385    -0.9188     0.358               (-9.747, 3.527)
str_dow_...09_05_00       2.35    2.568     0.9154     0.360               (-2.684, 7.385)
str_dow_...09_05_00     -2.136    2.775    -0.7699     0.441               (-7.576, 3.304)
str_dow_...09_05_00     -4.116    2.767     -1.488     0.137               (-9.541, 1.309)
str_dow_...09_05_00     -2.872    2.565      -1.12     0.263               (-7.903, 2.158)
str_dow_...09_05_00     0.1629    2.933    0.05554     0.956               (-5.589, 5.915)
 cp11_2012_01_02_00    -0.9717    2.264    -0.4292     0.668                (-5.41, 3.467)
is_weeke...01_02_00      4.318    1.988      2.172     0.030         *     (0.4204, 8.216)
str_dow_...01_02_00      3.124    4.186     0.7464     0.456               (-5.083, 11.33)
str_dow_...01_02_00     -1.483    3.164    -0.4686     0.639               (-7.686, 4.721)
str_dow_...01_02_00      3.597    3.429      1.049     0.294               (-3.126, 10.32)
str_dow_...01_02_00      8.685    3.427      2.534     0.011         *       (1.965, 15.4)
str_dow_...01_02_00      4.588     3.17      1.447     0.148                (-1.629, 10.8)
str_dow_...01_02_00    -0.2667    3.624    -0.0736     0.941                (-7.373, 6.84)
 cp12_2012_04_23_00     -5.821    1.289     -4.516  6.57e-06       ***    (-8.349, -3.294)
is_weeke...04_23_00     -2.184    1.168     -1.869     0.062         .     (-4.475, 0.107)
str_dow_...04_23_00     -1.986    2.466    -0.8054     0.421               (-6.821, 2.849)
str_dow_...04_23_00    -0.7837    1.866      -0.42     0.674               (-4.442, 2.875)
str_dow_...04_23_00     -2.082    2.026     -1.028     0.304               (-6.054, 1.891)
str_dow_...04_23_00     -5.412    2.021     -2.678     0.007        **    (-9.375, -1.449)
str_dow_...04_23_00     -2.536    1.865      -1.36     0.174               (-6.193, 1.121)
str_dow_...04_23_00     0.3504    2.134     0.1642     0.870               (-3.833, 4.534)
 cp13_2013_04_01_00       4.07   0.4333      9.393    <2e-16       ***        (3.22, 4.92)
is_weeke...04_01_00     0.2492   0.4097     0.6083     0.543              (-0.5541, 1.053)
str_dow_...04_01_00    0.06176   0.8687    0.07109     0.943               (-1.642, 1.765)
str_dow_...04_01_00      1.102   0.6584      1.674     0.094         .    (-0.1886, 2.393)
str_dow_...04_01_00     0.5137   0.7153     0.7182     0.473              (-0.8889, 1.916)
str_dow_...04_01_00      0.631   0.7105     0.8881     0.375              (-0.7622, 2.024)
str_dow_...04_01_00     0.6026   0.6553     0.9196     0.358              (-0.6823, 1.888)
str_dow_...04_01_00    -0.3528   0.7512    -0.4697     0.639                (-1.826, 1.12)
 cp14_2013_11_11_00     -2.269   0.2403      -9.44    <2e-16       ***     (-2.74, -1.797)
is_weeke...11_11_00     0.1677   0.2287     0.7334     0.463             (-0.2807, 0.6161)
str_dow_...11_11_00    0.01125   0.4823    0.02333     0.981              (-0.9345, 0.957)
str_dow_...11_11_00     -0.443   0.3658     -1.211     0.226               (-1.16, 0.2742)
str_dow_...11_11_00    -0.0236   0.3976   -0.05936     0.953              (-0.8032, 0.756)
str_dow_...11_11_00  -0.004941   0.3951   -0.01251     0.990             (-0.7796, 0.7697)
str_dow_...11_11_00     -0.258   0.3643    -0.7081     0.479             (-0.9723, 0.4564)
str_dow_...11_11_00     0.4253   0.4179      1.018     0.309              (-0.3941, 1.245)

There might be too many featuers for the trend (including interaction terms). Let’s hide the interaction terms.

202
203
204
205
206
207
208
209
 # Displays intercept, trend features but not seasonality features.
 # Hides interaction terms.
 summary.get_coef_summary(
     is_intercept=True,
     is_trend=True,
     is_seasonality=False,
     is_interaction=False
 )

Out:

          Pred_col Estimate Std. Err   t value  Pr(>|t|) sig. code              95%CI
         Intercept   0.7654  0.01626     47.08    <2e-16       ***   (0.7335, 0.7973)
               ct1   -1.636    3.574   -0.4576     0.647              (-8.643, 5.372)
 cp0_2008_03_31_00  -0.3919     5.62  -0.06974     0.944              (-11.41, 10.63)
 cp1_2008_07_21_00   -10.17    4.849    -2.096     0.036         *  (-19.67, -0.6577)
 cp2_2008_11_10_00     15.7    4.421     3.551  3.90e-04       ***     (7.032, 24.37)
 cp3_2009_03_09_00    5.416    4.241     1.277     0.202              (-2.901, 13.73)
 cp4_2009_06_29_00   -6.584    4.167     -1.58     0.114              (-14.76, 1.587)
 cp5_2009_10_19_00    1.156    3.834    0.3015     0.763              (-6.363, 8.674)
 cp6_2010_02_15_00   -15.29    3.668    -4.169  3.16e-05       ***   (-22.49, -8.099)
 cp7_2010_06_07_00    22.97    3.571     6.431  1.49e-10       ***     (15.96, 29.97)
 cp8_2010_09_27_00   -19.22    3.188    -6.029  1.87e-09       ***   (-25.47, -12.97)
 cp9_2011_01_24_00    9.753    2.134     4.571  5.06e-06       ***      (5.57, 13.94)
cp10_2011_09_05_00    1.309    1.875     0.698     0.485              (-2.367, 4.985)
cp11_2012_01_02_00  -0.9717    2.264   -0.4292     0.668               (-5.41, 3.467)
cp12_2012_04_23_00   -5.821    1.289    -4.516  6.57e-06       ***   (-8.349, -3.294)
cp13_2013_04_01_00     4.07   0.4333     9.393    <2e-16       ***       (3.22, 4.92)
cp14_2013_11_11_00   -2.269   0.2403     -9.44    <2e-16       ***    (-2.74, -1.797)

Now we can see the pure trend features, including the continuous growth term and trend changepoints. Each changepoint’s name starts with “cp” followed by the time point it happens. The estimated coefficients are the changes in slope at the corresponding changepoints. We can also see the significance of the changepoints by examining their p-values.

We can also retrieve the filtered dataframe by setting return_df to True. This way you could further explore the coefficients.

220
221
222
223
224
225
226
 output = summary.get_coef_summary(
     is_intercept=True,
     is_trend=True,
     is_seasonality=False,
     is_interaction=False,
     return_df=True  # returns the filtered df
 )

Out:

          Pred_col Estimate Std. Err   t value  Pr(>|t|) sig. code              95%CI
         Intercept   0.7654  0.01626     47.08    <2e-16       ***   (0.7335, 0.7973)
               ct1   -1.636    3.574   -0.4576     0.647              (-8.643, 5.372)
 cp0_2008_03_31_00  -0.3919     5.62  -0.06974     0.944              (-11.41, 10.63)
 cp1_2008_07_21_00   -10.17    4.849    -2.096     0.036         *  (-19.67, -0.6577)
 cp2_2008_11_10_00     15.7    4.421     3.551  3.90e-04       ***     (7.032, 24.37)
 cp3_2009_03_09_00    5.416    4.241     1.277     0.202              (-2.901, 13.73)
 cp4_2009_06_29_00   -6.584    4.167     -1.58     0.114              (-14.76, 1.587)
 cp5_2009_10_19_00    1.156    3.834    0.3015     0.763              (-6.363, 8.674)
 cp6_2010_02_15_00   -15.29    3.668    -4.169  3.16e-05       ***   (-22.49, -8.099)
 cp7_2010_06_07_00    22.97    3.571     6.431  1.49e-10       ***     (15.96, 29.97)
 cp8_2010_09_27_00   -19.22    3.188    -6.029  1.87e-09       ***   (-25.47, -12.97)
 cp9_2011_01_24_00    9.753    2.134     4.571  5.06e-06       ***      (5.57, 13.94)
cp10_2011_09_05_00    1.309    1.875     0.698     0.485              (-2.367, 4.985)
cp11_2012_01_02_00  -0.9717    2.264   -0.4292     0.668               (-5.41, 3.467)
cp12_2012_04_23_00   -5.821    1.289    -4.516  6.57e-06       ***   (-8.349, -3.294)
cp13_2013_04_01_00     4.07   0.4333     9.393    <2e-16       ***       (3.22, 4.92)
cp14_2013_11_11_00   -2.269   0.2403     -9.44    <2e-16       ***    (-2.74, -1.797)
1(1,2)

Reference: “An Introduction to Bootstrap”, Efron 1993.

2(1,2)

Reference: “High-Dimensional Inference: Confidence Intervals, p-Values and R-Software hdi”, Dezeure, Buhlmann, Meier and Meinshausen.

Total running time of the script: ( 0 minutes 27.417 seconds)

Gallery generated by Sphinx-Gallery