Note
Click here to download the full example code
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 import warnings
21
22 warnings.filterwarnings("ignore")
23
24 from greykite.common.data_loader import DataLoader
25 from greykite.framework.templates.autogen.forecast_config import ForecastConfig
26 from greykite.framework.templates.autogen.forecast_config import MetadataParam
27 from greykite.framework.templates.autogen.forecast_config import ModelComponentsParam
28 from greykite.framework.templates.model_templates import ModelTemplateEnum
29 from greykite.framework.templates.forecaster import Forecaster
30
31 # Loads dataset into pandas DataFrame
32 dl = DataLoader()
33 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 # Specifies dataset information
43 metadata = MetadataParam(
44 time_col="ts", # name of the time column
45 value_col="y", # name of the value column
46 freq="D" # "H" for hourly, "D" for daily, "W" for weekly, etc.
47 )
48
49 # Specifies model parameters
50 model_components = ModelComponentsParam(
51 changepoints={
52 "changepoints_dict": {
53 "method": "auto",
54 "potential_changepoint_n": 25,
55 "regularization_strength": 0.5,
56 "resample_freq": "7D",
57 "no_changepoint_distance_from_end": "365D"}
58 },
59 uncertainty={
60 "uncertainty_dict": "auto",
61 },
62 custom={
63 "fit_algorithm_dict": {
64 "fit_algorithm": "linear",
65 },
66 }
67 )
68
69 # Runs the forecast
70 forecaster = Forecaster()
71 result = forecaster.run_forecast_config(
72 df=df,
73 config=ForecastConfig(
74 model_template=ModelTemplateEnum.SILVERKITE.name,
75 forecast_horizon=365, # forecasts 365 steps ahead
76 coverage=0.95, # 95% prediction intervals
77 metadata_param=metadata,
78 model_components_param=model_components
79 )
80 )
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 # Initializes the model summary class.
89 # ``max_colwidth`` is the maximum length of predictor names that can be displayed.
90 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:
Model parameter section: includes basic model parameter information such as number of observations, number of features, model name and etc.
Model residual section: includes the five number summary of training residuals.
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.
Model coefficients section (for tree model): the feature significance.
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.).
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 # Prints the summary
115 print(summary)
Out:
============================ Forecast 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.263 -0.0486 0.179 3.429
Pred_col Estimate Std. Err t value Pr(>|t|) sig. code 95%CI
Intercept 0.7656 0.01628 47.02 <2e-16 *** (0.7336, 0.7975)
events_Chinese New Year 0.08247 0.1682 0.4903 0.624 (-0.2474, 0.4123)
events_Chinese New Year-1 -0.1794 0.1837 -0.9767 0.329 (-0.5395, 0.1807)
events_Chinese New Year-2 0.08999 0.1474 0.6107 0.541 (-0.199, 0.3789)
events_Chinese New Year+1 0.06618 0.1836 0.3604 0.719 (-0.2939, 0.4262)
events_Chinese New Year+2 0.1455 0.1473 0.9876 0.323 (-0.1434, 0.4343)
events_Christmas Day -0.5835 0.1806 -3.231 0.001 ** (-0.9377, -0.2294)
events_Christmas Day-1 -0.3327 0.1786 -1.863 0.063 . (-0.6829, 0.01756)
events_Christmas Day-2 -0.1279 0.1759 -0.7275 0.467 (-0.4728, 0.2169)
events_Christmas Day+1 -0.4459 0.1818 -2.453 0.014 * (-0.8024, -0.08939)
events_Christmas Day+2 0.09433 0.1811 0.5209 0.602 (-0.2608, 0.4494)
events_Easter...hern Ireland] -0.2267 0.1735 -1.307 0.191 (-0.567, 0.1135)
events_Easter...rn Ireland]-1 -0.1108 0.08676 -1.278 0.201 (-0.281, 0.05927)
events_Easter...rn Ireland]-2 -0.06303 0.08804 -0.7159 0.474 (-0.2357, 0.1096)
events_Easter...rn Ireland]+1 -0.09113 0.1735 -0.5252 0.600 (-0.4314, 0.2491)
events_Easter...rn Ireland]+2 -0.003141 0.1719 -0.01827 0.985 (-0.3403, 0.334)
events_Good Friday -0.183 0.1744 -1.05 0.294 (-0.525, 0.1589)
events_Good Friday-1 -0.1193 0.1721 -0.6933 0.488 (-0.4567, 0.2181)
events_Good Friday-2 -0.02276 0.1723 -0.1321 0.895 (-0.3607, 0.3151)
events_Good Friday+1 -0.06303 0.08804 -0.7159 0.474 (-0.2357, 0.1096)
events_Good Friday+2 -0.1108 0.08676 -1.278 0.201 (-0.281, 0.05927)
events_Independence Day 0.04982 0.1295 0.3849 0.700 (-0.204, 0.3037)
events_Independence Day-1 -0.01605 0.1294 -0.1241 0.901 (-0.2698, 0.2377)
events_Independence Day-2 -0.07617 0.129 -0.5903 0.555 (-0.3292, 0.1769)
events_Independence Day+1 -0.02978 0.1294 -0.2302 0.818 (-0.2834, 0.2239)
events_Independence Day+2 -0.03189 0.129 -0.2472 0.805 (-0.2848, 0.221)
events_Labor Day -0.4151 0.1272 -3.264 0.001 ** (-0.6644, -0.1657)
events_Labor Day-1 -0.1833 0.1271 -1.442 0.149 (-0.4326, 0.06599)
events_Labor Day-2 -0.07426 0.1269 -0.585 0.559 (-0.3232, 0.1747)
events_Labor Day+1 -0.2746 0.1271 -2.161 0.031 * (-0.5239, -0.02543)
events_Labor Day+2 -0.2364 0.1267 -1.866 0.062 . (-0.4847, 0.01201)
events_Memorial Day -0.4544 0.1796 -2.53 0.011 * (-0.8065, -0.1022)
events_Memorial Day-1 -0.2993 0.1796 -1.666 0.096 . (-0.6516, 0.05295)
events_Memorial Day-2 -0.151 0.1792 -0.8422 0.400 (-0.5024, 0.2005)
events_Memorial Day+1 -0.1565 0.1798 -0.8704 0.384 (-0.5089, 0.196)
events_Memorial Day+2 0.1362 0.1796 0.7583 0.448 (-0.216, 0.4884)
events_New Years Day -0.2528 0.1816 -1.392 0.164 (-0.609, 0.1033)
events_New Years Day-1 -0.02252 0.1837 -0.1226 0.902 (-0.3828, 0.3377)
events_New Years Day-2 0.1705 0.1832 0.9305 0.352 (-0.1888, 0.5298)
events_New Years Day+1 0.151 0.1799 0.8398 0.401 (-0.2016, 0.5037)
events_New Years Day+2 0.2824 0.1765 1.6 0.110 (-0.06359, 0.6284)
events_Other 0.01529 0.03065 0.4989 0.618 (-0.0448, 0.07539)
events_Other-1 0.01162 0.03039 0.3823 0.702 (-0.04797, 0.0712)
events_Other-2 0.031 0.03001 1.033 0.302 (-0.02785, 0.08985)
events_Other+1 0.01102 0.03076 0.3581 0.720 (-0.04929, 0.07133)
events_Other+2 0.01405 0.03043 0.4619 0.644 (-0.04561, 0.07372)
events_Thanksgiving -0.3788 0.1792 -2.114 0.035 * (-0.73, -0.02747)
events_Thanksgiving-1 -0.5798 0.1789 -3.24 0.001 ** (-0.9306, -0.2289)
events_Thanksgiving-2 -0.4231 0.1785 -2.371 0.018 * (-0.773, -0.07317)
events_Thanksgiving+1 -0.2715 0.1791 -1.516 0.130 (-0.6228, 0.07974)
events_Thanksgiving+2 -0.364 0.1788 -2.036 0.042 * (-0.7145, -0.01348)
events_Veterans Day 0.1113 0.1846 0.6026 0.547 (-0.2508, 0.4733)
events_Veterans Day-1 -0.001448 0.1843 -0.007854 0.994 (-0.3629, 0.36)
events_Veterans Day-2 -0.0196 0.1838 -0.1067 0.915 (-0.38, 0.3408)
events_Veterans Day+1 0.1001 0.1843 0.543 0.587 (-0.2613, 0.4614)
events_Veterans Day+2 0.009458 0.1832 0.05162 0.959 (-0.3499, 0.3688)
str_dow_2-Tue 0.02002 0.1026 0.1951 0.845 (-0.1812, 0.2213)
str_dow_3-Wed -0.06326 0.09959 -0.6352 0.525 (-0.2585, 0.132)
str_dow_4-Thu -0.07235 0.09757 -0.7415 0.458 (-0.2637, 0.119)
str_dow_5-Fri -0.2199 0.09802 -2.243 0.025 * (-0.4121, -0.02769)
str_dow_6-Sat -0.1621 0.1034 -1.567 0.117 (-0.3649, 0.0407)
str_dow_7-Sun 0.6027 0.1119 5.385 7.87e-08 *** (0.3832, 0.8221)
ct1 -1.617 3.574 -0.4524 0.651 (-8.626, 5.391)
is_weekend:ct1 0.07338 3.402 0.02157 0.983 (-6.598, 6.745)
str_dow_2-Tue:ct1 5.571 6.921 0.805 0.421 (-7.999, 19.14)
str_dow_3-Wed:ct1 1.88 5.331 0.3527 0.724 (-8.573, 12.33)
str_dow_4-Thu:ct1 13.84 5.825 2.375 0.018 * (2.414, 25.26)
str_dow_5-Fri:ct1 9.04 5.824 1.552 0.121 (-2.381, 20.46)
str_dow_6-Sat:ct1 6.408 5.464 1.173 0.241 (-4.306, 17.12)
str_dow_7-Sun:ct1 -6.333 6.256 -1.012 0.312 (-18.6, 5.935)
cp0_2008_03_31_00 -0.4259 5.62 -0.07578 0.940 (-11.45, 10.59)
is_weekend:cp0_2008_03_31_00 2.403 5.276 0.4555 0.649 (-7.942, 12.75)
str_dow_2-Tue...2008_03_31_00 -4.737 10.87 -0.4359 0.663 (-26.05, 16.57)
str_dow_3-Wed...2008_03_31_00 -2.265 8.35 -0.2712 0.786 (-18.64, 14.11)
str_dow_4-Thu...2008_03_31_00 -14.29 9.092 -1.572 0.116 (-32.12, 3.539)
str_dow_5-Fri...2008_03_31_00 -9.097 9.075 -1.002 0.316 (-26.89, 8.698)
str_dow_6-Sat...2008_03_31_00 -4.718 8.463 -0.5575 0.577 (-21.31, 11.88)
str_dow_7-Sun...2008_03_31_00 7.12 9.679 0.7356 0.462 (-11.86, 26.1)
cp1_2008_07_21_00 -10.14 4.849 -2.092 0.037 * (-19.65, -0.6345)
is_weekend:cp1_2008_07_21_00 -4.492 4.423 -1.016 0.310 (-13.16, 4.18)
str_dow_2-Tue...2008_07_21_00 -4.259 9.295 -0.4582 0.647 (-22.48, 13.97)
str_dow_3-Wed...2008_07_21_00 -3.999 7.105 -0.5628 0.574 (-17.93, 9.933)
str_dow_4-Thu...2008_07_21_00 -7.838 7.714 -1.016 0.310 (-22.96, 7.287)
str_dow_5-Fri...2008_07_21_00 -4.507 7.669 -0.5877 0.557 (-19.54, 10.53)
str_dow_6-Sat...2008_07_21_00 -8.095 7.092 -1.141 0.254 (-22.0, 5.811)
str_dow_7-Sun...2008_07_21_00 3.6 8.104 0.4442 0.657 (-12.29, 19.49)
cp2_2008_11_10_00 15.7 4.422 3.551 3.90e-04 *** (7.032, 24.37)
is_weekend:cp2_2008_11_10_00 4.0 4.043 0.9894 0.323 (-3.927, 11.93)
str_dow_2-Tue...2008_11_10_00 3.744 8.552 0.4379 0.662 (-13.02, 20.51)
str_dow_3-Wed...2008_11_10_00 7.801 6.513 1.198 0.231 (-4.969, 20.57)
str_dow_4-Thu...2008_11_10_00 15.78 7.069 2.233 0.026 * (1.921, 29.64)
str_dow_5-Fri...2008_11_10_00 9.427 7.013 1.344 0.179 (-4.323, 23.18)
str_dow_6-Sat...2008_11_10_00 10.45 6.481 1.612 0.107 (-2.262, 23.15)
str_dow_7-Sun...2008_11_10_00 -6.442 7.418 -0.8685 0.385 (-20.99, 8.103)
cp3_2009_03_09_00 5.406 4.242 1.274 0.203 (-2.912, 13.72)
is_weekend:cp3_2009_03_09_00 -0.1066 3.846 -0.02772 0.978 (-7.648, 7.435)
str_dow_2-Tue...2009_03_09_00 2.697 8.12 0.3321 0.740 (-13.22, 18.62)
str_dow_3-Wed...2009_03_09_00 -0.03976 6.169 -0.006445 0.995 (-12.14, 12.06)
str_dow_4-Thu...2009_03_09_00 -4.416 6.71 -0.6582 0.510 (-17.57, 8.74)
str_dow_5-Fri...2009_03_09_00 -2.239 6.669 -0.3357 0.737 (-15.32, 10.84)
str_dow_6-Sat...2009_03_09_00 -1.525 6.162 -0.2474 0.805 (-13.61, 10.56)
str_dow_7-Sun...2009_03_09_00 1.417 7.055 0.2009 0.841 (-12.42, 15.25)
cp4_2009_06_29_00 -6.591 4.168 -1.581 0.114 (-14.76, 1.583)
is_weekend:cp4_2009_06_29_00 -0.8796 3.795 -0.2318 0.817 (-8.321, 6.562)
str_dow_2-Tue...2009_06_29_00 -6.719 8.008 -0.839 0.402 (-22.42, 8.984)
str_dow_3-Wed...2009_06_29_00 -6.263 6.073 -1.031 0.302 (-18.17, 5.645)
str_dow_4-Thu...2009_06_29_00 -9.42 6.62 -1.423 0.155 (-22.4, 3.561)
str_dow_5-Fri...2009_06_29_00 -6.999 6.588 -1.062 0.288 (-19.92, 5.92)
str_dow_6-Sat...2009_06_29_00 -4.452 6.086 -0.7315 0.465 (-16.39, 7.482)
str_dow_7-Sun...2009_06_29_00 3.571 6.964 0.5128 0.608 (-10.08, 17.23)
cp5_2009_10_19_00 1.181 3.836 0.3079 0.758 (-6.34, 8.702)
is_weekend:cp5_2009_10_19_00 3.055 3.5 0.8729 0.383 (-3.808, 9.919)
str_dow_2-Tue...2009_10_19_00 3.196 7.403 0.4317 0.666 (-11.32, 17.71)
str_dow_3-Wed...2009_10_19_00 5.61 5.617 0.9988 0.318 (-5.404, 16.62)
str_dow_4-Thu...2009_10_19_00 10.27 6.111 1.681 0.093 . (-1.712, 22.25)
str_dow_5-Fri...2009_10_19_00 8.764 6.085 1.44 0.150 (-3.167, 20.69)
str_dow_6-Sat...2009_10_19_00 4.598 5.613 0.8191 0.413 (-6.409, 15.6)
str_dow_7-Sun...2009_10_19_00 -1.541 6.422 -0.2399 0.810 (-14.13, 11.05)
cp6_2010_02_15_00 -15.32 3.669 -4.177 3.05e-05 *** (-22.52, -8.13)
is_weekend:cp6_2010_02_15_00 -5.349 3.32 -1.611 0.107 (-11.86, 1.161)
str_dow_2-Tue...2010_02_15_00 3.287 7.006 0.4692 0.639 (-10.45, 17.03)
str_dow_3-Wed...2010_02_15_00 -3.022 5.318 -0.5682 0.570 (-13.45, 7.406)
str_dow_4-Thu...2010_02_15_00 2.625 5.785 0.4537 0.650 (-8.718, 13.97)
str_dow_5-Fri...2010_02_15_00 -1.445 5.764 -0.2507 0.802 (-12.75, 9.858)
str_dow_6-Sat...2010_02_15_00 -1.045 5.323 -0.1963 0.844 (-11.48, 9.392)
str_dow_7-Sun...2010_02_15_00 -4.304 6.089 -0.7069 0.480 (-16.24, 7.635)
cp7_2010_06_07_00 22.99 3.572 6.436 1.44e-10 *** (15.99, 29.99)
is_weekend:cp7_2010_06_07_00 4.75 3.243 1.465 0.143 (-1.608, 11.11)
str_dow_2-Tue...2010_06_07_00 -4.747 6.841 -0.694 0.488 (-18.16, 8.666)
str_dow_3-Wed...2010_06_07_00 -0.4483 5.193 -0.08632 0.931 (-10.63, 9.735)
str_dow_4-Thu...2010_06_07_00 -12.11 5.631 -2.15 0.032 * (-23.15, -1.065)
str_dow_5-Fri...2010_06_07_00 -6.269 5.613 -1.117 0.264 (-17.28, 4.736)
str_dow_6-Sat...2010_06_07_00 -3.618 5.197 -0.6962 0.486 (-13.81, 6.573)
str_dow_7-Sun...2010_06_07_00 8.366 5.942 1.408 0.159 (-3.285, 20.02)
cp8_2010_09_27_00 -19.22 3.189 -6.027 1.90e-09 *** (-25.47, -12.97)
is_weekend:cp8_2010_09_27_00 -2.232 2.835 -0.7872 0.431 (-7.791, 3.327)
str_dow_2-Tue...2010_09_27_00 -1.528 5.98 -0.2555 0.798 (-13.25, 10.2)
str_dow_3-Wed...2010_09_27_00 3.372 4.544 0.7421 0.458 (-5.538, 12.28)
str_dow_4-Thu...2010_09_27_00 9.618 4.919 1.955 0.051 . (-0.02648, 19.26)
str_dow_5-Fri...2010_09_27_00 5.361 4.898 1.095 0.274 (-4.242, 14.96)
str_dow_6-Sat...2010_09_27_00 4.142 4.534 0.9134 0.361 (-4.749, 13.03)
str_dow_7-Sun...2010_09_27_00 -6.371 5.183 -1.229 0.219 (-16.53, 3.792)
cp9_2011_01_24_00 9.736 2.134 4.563 5.26e-06 *** (5.552, 13.92)
is_weekend:cp9_2011_01_24_00 1.981 1.841 1.076 0.282 (-1.63, 5.591)
str_dow_2-Tue...2011_01_24_00 3.471 3.879 0.8948 0.371 (-4.135, 11.08)
str_dow_3-Wed...2011_01_24_00 -2.206 2.943 -0.7496 0.454 (-7.977, 3.565)
str_dow_4-Thu...2011_01_24_00 -1.881 3.19 -0.5898 0.555 (-8.136, 4.373)
str_dow_5-Fri...2011_01_24_00 -0.6717 3.178 -0.2114 0.833 (-6.903, 5.559)
str_dow_6-Sat...2011_01_24_00 -0.5041 2.94 -0.1715 0.864 (-6.269, 5.261)
str_dow_7-Sun...2011_01_24_00 2.485 3.364 0.7385 0.460 (-4.112, 9.081)
cp10_2011_09_05_00 1.313 1.875 0.7004 0.484 (-2.363, 4.989)
is_weekend:cp10_2011_09_05_00 -2.702 1.61 -1.678 0.093 . (-5.858, 0.4553)
str_dow_2-Tue...2011_09_05_00 -3.106 3.386 -0.9173 0.359 (-9.744, 3.533)
str_dow_3-Wed...2011_09_05_00 2.377 2.568 0.9255 0.355 (-2.659, 7.412)
str_dow_4-Thu...2011_09_05_00 -2.145 2.775 -0.7729 0.440 (-7.586, 3.296)
str_dow_5-Fri...2011_09_05_00 -4.108 2.767 -1.485 0.138 (-9.534, 1.318)
str_dow_6-Sat...2011_09_05_00 -2.85 2.566 -1.111 0.267 (-7.881, 2.181)
str_dow_7-Sun...2011_09_05_00 0.1469 2.934 0.05008 0.960 (-5.606, 5.9)
cp11_2012_01_02_00 -0.974 2.264 -0.4303 0.667 (-5.413, 3.465)
is_weekend:cp11_2012_01_02_00 4.327 1.988 2.177 0.030 * (0.4295, 8.225)
str_dow_2-Tue...2012_01_02_00 3.11 4.186 0.743 0.458 (-5.097, 11.32)
str_dow_3-Wed...2012_01_02_00 -1.512 3.164 -0.478 0.633 (-7.716, 4.691)
str_dow_4-Thu...2012_01_02_00 3.594 3.429 1.048 0.295 (-3.13, 10.32)
str_dow_5-Fri...2012_01_02_00 8.673 3.427 2.531 0.011 * (1.954, 15.39)
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.2576 3.624 -0.07108 0.943 (-7.364, 6.848)
cp12_2012_04_23_00 -5.817 1.289 -4.513 6.67e-06 *** (-8.345, -3.29)
is_weekend:cp12_2012_04_23_00 -2.195 1.168 -1.879 0.060 . (-4.486, 0.09546)
str_dow_2-Tue...2012_04_23_00 -1.981 2.466 -0.8034 0.422 (-6.816, 2.854)
str_dow_3-Wed...2012_04_23_00 -0.7724 1.866 -0.414 0.679 (-4.431, 2.886)
str_dow_4-Thu...2012_04_23_00 -2.073 2.026 -1.023 0.306 (-6.045, 1.9)
str_dow_5-Fri...2012_04_23_00 -5.407 2.021 -2.675 0.008 ** (-9.369, -1.444)
str_dow_6-Sat...2012_04_23_00 -2.542 1.865 -1.363 0.173 (-6.198, 1.115)
str_dow_7-Sun...2012_04_23_00 0.3443 2.134 0.1614 0.872 (-3.839, 4.528)
cp13_2013_04_01_00 4.068 0.4334 9.387 <2e-16 *** (3.219, 4.918)
is_weekend:cp13_2013_04_01_00 0.2496 0.4097 0.6091 0.543 (-0.5538, 1.053)
str_dow_2-Tue...2013_04_01_00 0.0595 0.8689 0.06848 0.945 (-1.644, 1.763)
str_dow_3-Wed...2013_04_01_00 1.103 0.6585 1.674 0.094 . (-0.1886, 2.394)
str_dow_4-Thu...2013_04_01_00 0.5104 0.7155 0.7134 0.476 (-0.8925, 1.913)
str_dow_5-Fri...2013_04_01_00 0.6306 0.7106 0.8874 0.375 (-0.7628, 2.024)
str_dow_6-Sat...2013_04_01_00 0.6009 0.6554 0.9169 0.359 (-0.6842, 1.886)
str_dow_7-Sun...2013_04_01_00 -0.3507 0.7513 -0.4669 0.641 (-1.824, 1.122)
cp14_2013_11_11_00 -2.268 0.2404 -9.435 <2e-16 *** (-2.739, -1.797)
is_weekend:cp14_2013_11_11_00 0.1686 0.2287 0.7369 0.461 (-0.2799, 0.617)
str_dow_2-Tue...2013_11_11_00 0.01531 0.4825 0.03173 0.975 (-0.9308, 0.9614)
str_dow_3-Wed...2013_11_11_00 -0.4436 0.3659 -1.212 0.225 (-1.161, 0.2739)
str_dow_4-Thu...2013_11_11_00 -0.02313 0.3977 -0.05815 0.954 (-0.803, 0.7567)
str_dow_5-Fri...2013_11_11_00 -0.004637 0.3952 -0.01174 0.991 (-0.7795, 0.7702)
str_dow_6-Sat...2013_11_11_00 -0.2572 0.3644 -0.7059 0.480 (-0.9717, 0.4573)
str_dow_7-Sun...2013_11_11_00 0.4255 0.418 1.018 0.309 (-0.3941, 1.245)
ct1:sin1_tow_weekly 3.96 3.362 1.178 0.239 (-2.633, 10.55)
ct1:cos1_tow_weekly -28.53 6.38 -4.472 8.08e-06 *** (-41.04, -16.02)
ct1:sin2_tow_weekly 5.421 4.103 1.321 0.187 (-2.625, 13.47)
ct1:cos2_tow_weekly -12.81 5.596 -2.289 0.022 * (-23.78, -1.835)
cp0_2008_03_3...n1_tow_weekly -4.3 5.247 -0.8195 0.413 (-14.59, 5.989)
cp0_2008_03_3...s1_tow_weekly 27.53 10.02 2.747 0.006 ** (7.877, 47.18)
cp0_2008_03_3...n2_tow_weekly -4.012 6.382 -0.6288 0.530 (-16.53, 8.501)
cp0_2008_03_3...s2_tow_weekly 10.21 8.798 1.161 0.246 (-7.038, 27.47)
cp1_2008_07_2...n1_tow_weekly -1.465 4.441 -0.3299 0.742 (-10.17, 7.243)
cp1_2008_07_2...s1_tow_weekly 15.27 8.565 1.782 0.075 . (-1.528, 32.06)
cp1_2008_07_2...n2_tow_weekly -3.123 5.383 -0.5802 0.562 (-13.68, 7.432)
cp1_2008_07_2...s2_tow_weekly 9.978 7.533 1.325 0.185 (-4.793, 24.75)
cp2_2008_11_1...n1_tow_weekly 4.562 4.064 1.122 0.262 (-3.407, 12.53)
cp2_2008_11_1...s1_tow_weekly -27.76 7.855 -3.534 4.16e-04 *** (-43.16, -12.36)
cp2_2008_11_1...n2_tow_weekly 3.518 4.926 0.7143 0.475 (-6.14, 13.18)
cp2_2008_11_1...s2_tow_weekly -12.86 6.915 -1.86 0.063 . (-26.42, 0.6954)
cp3_2009_03_0...n1_tow_weekly 1.154 3.857 0.2993 0.765 (-6.408, 8.717)
cp3_2009_03_0...s1_tow_weekly 10.05 7.471 1.345 0.179 (-4.599, 24.7)
cp3_2009_03_0...n2_tow_weekly 1.564 4.668 0.3351 0.738 (-7.588, 10.72)
cp3_2009_03_0...s2_tow_weekly 3.441 6.57 0.5238 0.600 (-9.442, 16.32)
cp4_2009_06_2...n1_tow_weekly -5.191 3.802 -1.365 0.172 (-12.65, 2.263)
cp4_2009_06_2...s1_tow_weekly 20.82 7.371 2.824 0.005 ** (6.362, 35.27)
cp4_2009_06_2...n2_tow_weekly -3.39 4.602 -0.7365 0.461 (-12.41, 5.634)
cp4_2009_06_2...s2_tow_weekly 12.88 6.481 1.987 0.047 * (0.1704, 25.59)
cp5_2009_10_1...n1_tow_weekly 3.126 3.513 0.8899 0.374 (-3.762, 10.01)
cp5_2009_10_1...s1_tow_weekly -24.93 6.805 -3.664 2.53e-04 *** (-38.27, -11.59)
cp5_2009_10_1...n2_tow_weekly 1.922 4.25 0.4523 0.651 (-6.411, 10.26)
cp5_2009_10_1...s2_tow_weekly -14.05 5.983 -2.348 0.019 * (-25.78, -2.317)
cp6_2010_02_1...n1_tow_weekly 3.34 3.332 1.002 0.316 (-3.194, 9.874)
cp6_2010_02_1...s1_tow_weekly -6.07 6.454 -0.9405 0.347 (-18.73, 6.586)
cp6_2010_02_1...n2_tow_weekly 2.99 4.025 0.7429 0.458 (-4.902, 10.88)
cp6_2010_02_1...s2_tow_weekly -3.217 5.662 -0.5682 0.570 (-14.32, 7.885)
cp7_2010_06_0...n1_tow_weekly -4.588 3.254 -1.41 0.159 (-10.97, 1.793)
cp7_2010_06_0...s1_tow_weekly 32.73 6.297 5.198 2.16e-07 *** (20.38, 45.08)
cp7_2010_06_0...n2_tow_weekly -4.543 3.932 -1.155 0.248 (-12.25, 3.168)
cp7_2010_06_0...s2_tow_weekly 17.83 5.536 3.221 0.001 ** (6.979, 28.69)
cp8_2010_09_2...n1_tow_weekly 2.887 2.844 1.015 0.310 (-2.69, 8.463)
cp8_2010_09_2...s1_tow_weekly -28.0 5.501 -5.09 3.83e-07 *** (-38.78, -17.21)
cp8_2010_09_2...n2_tow_weekly 1.269 3.441 0.3689 0.712 (-5.477, 8.016)
cp8_2010_09_2...s2_tow_weekly -15.15 4.849 -3.124 0.002 ** (-24.65, -5.638)
cp9_2011_01_2...n1_tow_weekly -0.3419 1.845 -0.1853 0.853 (-3.961, 3.277)
cp9_2011_01_2...s1_tow_weekly 8.609 3.572 2.41 0.016 * (1.604, 15.61)
cp9_2011_01_2...n2_tow_weekly 1.74 2.23 0.7804 0.435 (-2.632, 6.113)
cp9_2011_01_2...s2_tow_weekly 4.875 3.149 1.548 0.122 (-1.3, 11.05)
cp10_2011_09_...n1_tow_weekly 2.127 1.613 1.319 0.187 (-1.036, 5.29)
cp10_2011_09_...s1_tow_weekly 8.188 3.122 2.623 0.009 ** (2.066, 14.31)
cp10_2011_09_...n2_tow_weekly -3.194 1.949 -1.639 0.101 (-7.015, 0.6267)
cp10_2011_09_...s2_tow_weekly 4.659 2.751 1.694 0.090 . (-0.7345, 10.05)
cp11_2012_01_...n1_tow_weekly -2.443 1.995 -1.225 0.221 (-6.355, 1.469)
cp11_2012_01_...s1_tow_weekly -14.94 3.858 -3.873 1.10e-04 *** (-22.51, -7.378)
cp11_2012_01_...n2_tow_weekly 5.457 2.405 2.269 0.023 * (0.7423, 10.17)
cp11_2012_01_...s2_tow_weekly -7.472 3.389 -2.205 0.028 * (-14.12, -0.8278)
cp12_2012_04_...n1_tow_weekly 1.072 1.173 0.9137 0.361 (-1.229, 3.373)
cp12_2012_04_...s1_tow_weekly 7.22 2.271 3.18 0.001 ** (2.768, 11.67)
cp12_2012_04_...n2_tow_weekly -2.508 1.415 -1.773 0.076 . (-5.282, 0.2664)
cp12_2012_04_...s2_tow_weekly 3.139 1.994 1.574 0.116 (-0.7705, 7.049)
cp13_2013_04_...n1_tow_weekly 0.7722 0.4107 1.88 0.060 . (-0.03309, 1.577)
cp13_2013_04_...s1_tow_weekly 0.3308 0.7964 0.4154 0.678 (-1.231, 1.892)
cp13_2013_04_...n2_tow_weekly 0.5232 0.4984 1.05 0.294 (-0.4541, 1.501)
cp13_2013_04_...s2_tow_weekly 0.7644 0.7023 1.088 0.276 (-0.6127, 2.142)
cp14_2013_11_...n1_tow_weekly 0.1194 0.2284 0.5228 0.601 (-0.3285, 0.5674)
cp14_2013_11_...s1_tow_weekly -0.4439 0.4424 -1.003 0.316 (-1.311, 0.4237)
cp14_2013_11_...n2_tow_weekly 0.2267 0.2781 0.8153 0.415 (-0.3186, 0.7721)
cp14_2013_11_...s2_tow_weekly -0.4081 0.3913 -1.043 0.297 (-1.175, 0.359)
sin1_tow_weekly 0.2314 0.1094 2.116 0.034 * (0.01696, 0.4459)
cos1_tow_weekly 1.079 0.1402 7.699 1.90e-14 *** (0.8045, 1.354)
sin2_tow_weekly 0.0103 0.1097 0.09383 0.925 (-0.2048, 0.2254)
cos2_tow_weekly 0.6484 0.1395 4.649 3.49e-06 *** (0.3749, 0.9218)
sin3_tow_weekly 0.2873 0.07488 3.836 1.28e-04 *** (0.1404, 0.4341)
cos3_tow_weekly 0.3754 0.1399 2.684 0.007 ** (0.1011, 0.6498)
sin4_tow_weekly 0.4783 0.07393 6.47 1.15e-10 *** (0.3333, 0.6233)
sin4_toq_quarterly -0.003142 0.02559 -0.1228 0.902 (-0.05333, 0.04704)
cos4_toq_quarterly -0.07919 0.02634 -3.006 0.003 ** (-0.1308, -0.02753)
sin5_toq_quarterly -0.07704 0.02623 -2.937 0.003 ** (-0.1285, -0.02561)
cos5_toq_quarterly 0.03787 0.02599 1.457 0.145 (-0.01309, 0.08883)
sin1_ct1_yearly -0.2079 0.03574 -5.816 6.71e-09 *** (-0.278, -0.1378)
cos1_ct1_yearly 1.489 0.03574 41.65 <2e-16 *** (1.419, 1.559)
sin2_ct1_yearly 0.1157 0.02821 4.101 4.24e-05 *** (0.06035, 0.171)
cos2_ct1_yearly -0.1826 0.02749 -6.643 3.68e-11 *** (-0.2365, -0.1287)
sin3_ct1_yearly 0.513 0.02794 18.36 <2e-16 *** (0.4582, 0.5678)
cos3_ct1_yearly -0.09111 0.02657 -3.429 6.15e-04 *** (-0.1432, -0.03901)
sin4_ct1_yearly 0.005083 0.0276 0.1842 0.854 (-0.04904, 0.0592)
cos4_ct1_yearly -0.2153 0.02518 -8.553 <2e-16 *** (-0.2647, -0.166)
sin5_ct1_yearly -0.1971 0.02769 -7.117 1.40e-12 *** (-0.2514, -0.1428)
cos5_ct1_yearly -0.03295 0.02519 -1.308 0.191 (-0.08234, 0.01645)
sin6_ct1_yearly -0.2464 0.02745 -8.975 <2e-16 *** (-0.3002, -0.1925)
cos6_ct1_yearly -0.05704 0.0262 -2.177 0.030 * (-0.1084, -0.005666)
sin7_ct1_yearly -0.1074 0.02684 -4.002 6.44e-05 *** (-0.16, -0.05479)
cos7_ct1_yearly 0.08863 0.02584 3.43 6.13e-04 *** (0.03795, 0.1393)
sin8_ct1_yearly 0.06806 0.02614 2.604 0.009 ** (0.01681, 0.1193)
cos8_ct1_yearly 0.2172 0.02732 7.951 2.67e-15 *** (0.1637, 0.2708)
sin9_ct1_yearly 0.008004 0.02618 0.3057 0.760 (-0.04334, 0.05934)
cos9_ct1_yearly -0.0616 0.02752 -2.238 0.025 * (-0.1156, -0.007634)
sin10_ct1_yearly -0.1489 0.02627 -5.666 1.61e-08 *** (-0.2004, -0.09734)
cos10_ct1_yearly -0.1346 0.0265 -5.078 4.07e-07 *** (-0.1866, -0.08262)
sin11_ct1_yearly -0.03787 0.0259 -1.462 0.144 (-0.08865, 0.01291)
cos11_ct1_yearly -0.0325 0.0266 -1.222 0.222 (-0.08465, 0.01965)
sin12_ct1_yearly -0.03812 0.02667 -1.429 0.153 (-0.09041, 0.01417)
cos12_ct1_yearly 0.02289 0.02665 0.859 0.390 (-0.02936, 0.07514)
sin13_ct1_yearly -0.01921 0.02545 -0.7548 0.450 (-0.06912, 0.0307)
cos13_ct1_yearly 0.0966 0.02736 3.53 4.22e-04 *** (0.04294, 0.1503)
sin14_ct1_yearly 0.07453 0.02602 2.864 0.004 ** (0.02351, 0.1255)
cos14_ct1_yearly -0.03612 0.02728 -1.324 0.186 (-0.0896, 0.01736)
sin15_ct1_yearly 0.04725 0.02631 1.796 0.073 . (-0.004336, 0.09883)
cos15_ct1_yearly -0.05931 0.02625 -2.259 0.024 * (-0.1108, -0.007831)
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.848 on 205 and 2757 DF, p-value: 1.110e-16
Model AIC: 19344.0, model BIC: 20579.0
WARNING: the condition number is large, 5.53e+19. This might indicate that there are strong multicollinearity or other numerical problems.
The model summary provides useful insights:
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.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:
High feature correlation can increase the coefficient variance. This is common in forecasting problems, so we recommend regularized models.
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 # Prints the keys of the ``info_dict`` dictionary.
152 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 # The above coefficient summary can be accessed as a pandas Dataframe.
157 print(summary.info_dict["coef_summary_df"])
Out:
Pred_col Estimate ... sig. code 95%CI
0 Intercept 0.765558 ... *** (0.7336308536739108, 0.7974850018054168)
1 C(Q('events_Chinese New Year'), levels=['', 'e... 0.082468 ... (-0.2473675440147719, 0.41230377791077844)
2 C(Q('events_Chinese New Year_minus_1'), levels... -0.179376 ... (-0.5394848721077399, 0.18073315433364434)
3 C(Q('events_Chinese New Year_minus_2'), levels... 0.089987 ... (-0.19896305686957588, 0.378936161016139)
4 C(Q('events_Chinese New Year_plus_1'), levels=... 0.066183 ... (-0.29386106670631423, 0.4262267618197744)
.. ... ... ... ... ...
290 cos13_ct1_yearly 0.096599 ... *** (0.042941864711931996, 0.1502569350368892)
291 sin14_ct1_yearly 0.074528 ... ** (0.023510785892640003, 0.12554509494194394)
292 cos14_ct1_yearly -0.036120 ... (-0.08960242434207752, 0.01736161866240301)
293 sin15_ct1_yearly 0.047247 ... . (-0.0043364838492392505, 0.09883077499983518)
294 cos15_ct1_yearly -0.059309 ... * (-0.11078603712871057, -0.007831094195667798)
[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 inbuild_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 # Displays intercept, trend features but not seasonality features.
192 summary.get_coef_summary(
193 is_intercept=True,
194 is_trend=True,
195 is_seasonality=False
196 )
Out:
Pred_col Estimate Std. Err t value Pr(>|t|) sig. code 95%CI
Intercept 0.7656 0.01628 47.02 <2e-16 *** (0.7336, 0.7975)
ct1 -1.617 3.574 -0.4524 0.651 (-8.626, 5.391)
is_weekend:ct1 0.07338 3.402 0.02157 0.983 (-6.598, 6.745)
str_dow_2-Tue:ct1 5.571 6.921 0.805 0.421 (-7.999, 19.14)
str_dow_3-Wed:ct1 1.88 5.331 0.3527 0.724 (-8.573, 12.33)
str_dow_4-Thu:ct1 13.84 5.825 2.375 0.018 * (2.414, 25.26)
str_dow_5-Fri:ct1 9.04 5.824 1.552 0.121 (-2.381, 20.46)
str_dow_6-Sat:ct1 6.408 5.464 1.173 0.241 (-4.306, 17.12)
str_dow_7-Sun:ct1 -6.333 6.256 -1.012 0.312 (-18.6, 5.935)
cp0_2008_03_31_00 -0.4259 5.62 -0.07578 0.940 (-11.45, 10.59)
is_weeke...03_31_00 2.403 5.276 0.4555 0.649 (-7.942, 12.75)
str_dow_...03_31_00 -4.737 10.87 -0.4359 0.663 (-26.05, 16.57)
str_dow_...03_31_00 -2.265 8.35 -0.2712 0.786 (-18.64, 14.11)
str_dow_...03_31_00 -14.29 9.092 -1.572 0.116 (-32.12, 3.539)
str_dow_...03_31_00 -9.097 9.075 -1.002 0.316 (-26.89, 8.698)
str_dow_...03_31_00 -4.718 8.463 -0.5575 0.577 (-21.31, 11.88)
str_dow_...03_31_00 7.12 9.679 0.7356 0.462 (-11.86, 26.1)
cp1_2008_07_21_00 -10.14 4.849 -2.092 0.037 * (-19.65, -0.6345)
is_weeke...07_21_00 -4.492 4.423 -1.016 0.310 (-13.16, 4.18)
str_dow_...07_21_00 -4.259 9.295 -0.4582 0.647 (-22.48, 13.97)
str_dow_...07_21_00 -3.999 7.105 -0.5628 0.574 (-17.93, 9.933)
str_dow_...07_21_00 -7.838 7.714 -1.016 0.310 (-22.96, 7.287)
str_dow_...07_21_00 -4.507 7.669 -0.5877 0.557 (-19.54, 10.53)
str_dow_...07_21_00 -8.095 7.092 -1.141 0.254 (-22.0, 5.811)
str_dow_...07_21_00 3.6 8.104 0.4442 0.657 (-12.29, 19.49)
cp2_2008_11_10_00 15.7 4.422 3.551 3.90e-04 *** (7.032, 24.37)
is_weeke...11_10_00 4.0 4.043 0.9894 0.323 (-3.927, 11.93)
str_dow_...11_10_00 3.744 8.552 0.4379 0.662 (-13.02, 20.51)
str_dow_...11_10_00 7.801 6.513 1.198 0.231 (-4.969, 20.57)
str_dow_...11_10_00 15.78 7.069 2.233 0.026 * (1.921, 29.64)
str_dow_...11_10_00 9.427 7.013 1.344 0.179 (-4.323, 23.18)
str_dow_...11_10_00 10.45 6.481 1.612 0.107 (-2.262, 23.15)
str_dow_...11_10_00 -6.442 7.418 -0.8685 0.385 (-20.99, 8.103)
cp3_2009_03_09_00 5.406 4.242 1.274 0.203 (-2.912, 13.72)
is_weeke...03_09_00 -0.1066 3.846 -0.02772 0.978 (-7.648, 7.435)
str_dow_...03_09_00 2.697 8.12 0.3321 0.740 (-13.22, 18.62)
str_dow_...03_09_00 -0.03976 6.169 -0.006445 0.995 (-12.14, 12.06)
str_dow_...03_09_00 -4.416 6.71 -0.6582 0.510 (-17.57, 8.74)
str_dow_...03_09_00 -2.239 6.669 -0.3357 0.737 (-15.32, 10.84)
str_dow_...03_09_00 -1.525 6.162 -0.2474 0.805 (-13.61, 10.56)
str_dow_...03_09_00 1.417 7.055 0.2009 0.841 (-12.42, 15.25)
cp4_2009_06_29_00 -6.591 4.168 -1.581 0.114 (-14.76, 1.583)
is_weeke...06_29_00 -0.8796 3.795 -0.2318 0.817 (-8.321, 6.562)
str_dow_...06_29_00 -6.719 8.008 -0.839 0.402 (-22.42, 8.984)
str_dow_...06_29_00 -6.263 6.073 -1.031 0.302 (-18.17, 5.645)
str_dow_...06_29_00 -9.42 6.62 -1.423 0.155 (-22.4, 3.561)
str_dow_...06_29_00 -6.999 6.588 -1.062 0.288 (-19.92, 5.92)
str_dow_...06_29_00 -4.452 6.086 -0.7315 0.465 (-16.39, 7.482)
str_dow_...06_29_00 3.571 6.964 0.5128 0.608 (-10.08, 17.23)
cp5_2009_10_19_00 1.181 3.836 0.3079 0.758 (-6.34, 8.702)
is_weeke...10_19_00 3.055 3.5 0.8729 0.383 (-3.808, 9.919)
str_dow_...10_19_00 3.196 7.403 0.4317 0.666 (-11.32, 17.71)
str_dow_...10_19_00 5.61 5.617 0.9988 0.318 (-5.404, 16.62)
str_dow_...10_19_00 10.27 6.111 1.681 0.093 . (-1.712, 22.25)
str_dow_...10_19_00 8.764 6.085 1.44 0.150 (-3.167, 20.69)
str_dow_...10_19_00 4.598 5.613 0.8191 0.413 (-6.409, 15.6)
str_dow_...10_19_00 -1.541 6.422 -0.2399 0.810 (-14.13, 11.05)
cp6_2010_02_15_00 -15.32 3.669 -4.177 3.05e-05 *** (-22.52, -8.13)
is_weeke...02_15_00 -5.349 3.32 -1.611 0.107 (-11.86, 1.161)
str_dow_...02_15_00 3.287 7.006 0.4692 0.639 (-10.45, 17.03)
str_dow_...02_15_00 -3.022 5.318 -0.5682 0.570 (-13.45, 7.406)
str_dow_...02_15_00 2.625 5.785 0.4537 0.650 (-8.718, 13.97)
str_dow_...02_15_00 -1.445 5.764 -0.2507 0.802 (-12.75, 9.858)
str_dow_...02_15_00 -1.045 5.323 -0.1963 0.844 (-11.48, 9.392)
str_dow_...02_15_00 -4.304 6.089 -0.7069 0.480 (-16.24, 7.635)
cp7_2010_06_07_00 22.99 3.572 6.436 1.44e-10 *** (15.99, 29.99)
is_weeke...06_07_00 4.75 3.243 1.465 0.143 (-1.608, 11.11)
str_dow_...06_07_00 -4.747 6.841 -0.694 0.488 (-18.16, 8.666)
str_dow_...06_07_00 -0.4483 5.193 -0.08632 0.931 (-10.63, 9.735)
str_dow_...06_07_00 -12.11 5.631 -2.15 0.032 * (-23.15, -1.065)
str_dow_...06_07_00 -6.269 5.613 -1.117 0.264 (-17.28, 4.736)
str_dow_...06_07_00 -3.618 5.197 -0.6962 0.486 (-13.81, 6.573)
str_dow_...06_07_00 8.366 5.942 1.408 0.159 (-3.285, 20.02)
cp8_2010_09_27_00 -19.22 3.189 -6.027 1.90e-09 *** (-25.47, -12.97)
is_weeke...09_27_00 -2.232 2.835 -0.7872 0.431 (-7.791, 3.327)
str_dow_...09_27_00 -1.528 5.98 -0.2555 0.798 (-13.25, 10.2)
str_dow_...09_27_00 3.372 4.544 0.7421 0.458 (-5.538, 12.28)
str_dow_...09_27_00 9.618 4.919 1.955 0.051 . (-0.02648, 19.26)
str_dow_...09_27_00 5.361 4.898 1.095 0.274 (-4.242, 14.96)
str_dow_...09_27_00 4.142 4.534 0.9134 0.361 (-4.749, 13.03)
str_dow_...09_27_00 -6.371 5.183 -1.229 0.219 (-16.53, 3.792)
cp9_2011_01_24_00 9.736 2.134 4.563 5.26e-06 *** (5.552, 13.92)
is_weeke...01_24_00 1.981 1.841 1.076 0.282 (-1.63, 5.591)
str_dow_...01_24_00 3.471 3.879 0.8948 0.371 (-4.135, 11.08)
str_dow_...01_24_00 -2.206 2.943 -0.7496 0.454 (-7.977, 3.565)
str_dow_...01_24_00 -1.881 3.19 -0.5898 0.555 (-8.136, 4.373)
str_dow_...01_24_00 -0.6717 3.178 -0.2114 0.833 (-6.903, 5.559)
str_dow_...01_24_00 -0.5041 2.94 -0.1715 0.864 (-6.269, 5.261)
str_dow_...01_24_00 2.485 3.364 0.7385 0.460 (-4.112, 9.081)
cp10_2011_09_05_00 1.313 1.875 0.7004 0.484 (-2.363, 4.989)
is_weeke...09_05_00 -2.702 1.61 -1.678 0.093 . (-5.858, 0.4553)
str_dow_...09_05_00 -3.106 3.386 -0.9173 0.359 (-9.744, 3.533)
str_dow_...09_05_00 2.377 2.568 0.9255 0.355 (-2.659, 7.412)
str_dow_...09_05_00 -2.145 2.775 -0.7729 0.440 (-7.586, 3.296)
str_dow_...09_05_00 -4.108 2.767 -1.485 0.138 (-9.534, 1.318)
str_dow_...09_05_00 -2.85 2.566 -1.111 0.267 (-7.881, 2.181)
str_dow_...09_05_00 0.1469 2.934 0.05008 0.960 (-5.606, 5.9)
cp11_2012_01_02_00 -0.974 2.264 -0.4303 0.667 (-5.413, 3.465)
is_weeke...01_02_00 4.327 1.988 2.177 0.030 * (0.4295, 8.225)
str_dow_...01_02_00 3.11 4.186 0.743 0.458 (-5.097, 11.32)
str_dow_...01_02_00 -1.512 3.164 -0.478 0.633 (-7.716, 4.691)
str_dow_...01_02_00 3.594 3.429 1.048 0.295 (-3.13, 10.32)
str_dow_...01_02_00 8.673 3.427 2.531 0.011 * (1.954, 15.39)
str_dow_...01_02_00 4.588 3.17 1.447 0.148 (-1.629, 10.8)
str_dow_...01_02_00 -0.2576 3.624 -0.07108 0.943 (-7.364, 6.848)
cp12_2012_04_23_00 -5.817 1.289 -4.513 6.67e-06 *** (-8.345, -3.29)
is_weeke...04_23_00 -2.195 1.168 -1.879 0.060 . (-4.486, 0.09546)
str_dow_...04_23_00 -1.981 2.466 -0.8034 0.422 (-6.816, 2.854)
str_dow_...04_23_00 -0.7724 1.866 -0.414 0.679 (-4.431, 2.886)
str_dow_...04_23_00 -2.073 2.026 -1.023 0.306 (-6.045, 1.9)
str_dow_...04_23_00 -5.407 2.021 -2.675 0.008 ** (-9.369, -1.444)
str_dow_...04_23_00 -2.542 1.865 -1.363 0.173 (-6.198, 1.115)
str_dow_...04_23_00 0.3443 2.134 0.1614 0.872 (-3.839, 4.528)
cp13_2013_04_01_00 4.068 0.4334 9.387 <2e-16 *** (3.219, 4.918)
is_weeke...04_01_00 0.2496 0.4097 0.6091 0.543 (-0.5538, 1.053)
str_dow_...04_01_00 0.0595 0.8689 0.06848 0.945 (-1.644, 1.763)
str_dow_...04_01_00 1.103 0.6585 1.674 0.094 . (-0.1886, 2.394)
str_dow_...04_01_00 0.5104 0.7155 0.7134 0.476 (-0.8925, 1.913)
str_dow_...04_01_00 0.6306 0.7106 0.8874 0.375 (-0.7628, 2.024)
str_dow_...04_01_00 0.6009 0.6554 0.9169 0.359 (-0.6842, 1.886)
str_dow_...04_01_00 -0.3507 0.7513 -0.4669 0.641 (-1.824, 1.122)
cp14_2013_11_11_00 -2.268 0.2404 -9.435 <2e-16 *** (-2.739, -1.797)
is_weeke...11_11_00 0.1686 0.2287 0.7369 0.461 (-0.2799, 0.617)
str_dow_...11_11_00 0.01531 0.4825 0.03173 0.975 (-0.9308, 0.9614)
str_dow_...11_11_00 -0.4436 0.3659 -1.212 0.225 (-1.161, 0.2739)
str_dow_...11_11_00 -0.02313 0.3977 -0.05815 0.954 (-0.803, 0.7567)
str_dow_...11_11_00 -0.004637 0.3952 -0.01174 0.991 (-0.7795, 0.7702)
str_dow_...11_11_00 -0.2572 0.3644 -0.7059 0.480 (-0.9717, 0.4573)
str_dow_...11_11_00 0.4255 0.418 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 # Displays intercept, trend features but not seasonality features.
203 # Hides interaction terms.
204 summary.get_coef_summary(
205 is_intercept=True,
206 is_trend=True,
207 is_seasonality=False,
208 is_interaction=False
209 )
Out:
Pred_col Estimate Std. Err t value Pr(>|t|) sig. code 95%CI
Intercept 0.7656 0.01628 47.02 <2e-16 *** (0.7336, 0.7975)
ct1 -1.617 3.574 -0.4524 0.651 (-8.626, 5.391)
cp0_2008_03_31_00 -0.4259 5.62 -0.07578 0.940 (-11.45, 10.59)
cp1_2008_07_21_00 -10.14 4.849 -2.092 0.037 * (-19.65, -0.6345)
cp2_2008_11_10_00 15.7 4.422 3.551 3.90e-04 *** (7.032, 24.37)
cp3_2009_03_09_00 5.406 4.242 1.274 0.203 (-2.912, 13.72)
cp4_2009_06_29_00 -6.591 4.168 -1.581 0.114 (-14.76, 1.583)
cp5_2009_10_19_00 1.181 3.836 0.3079 0.758 (-6.34, 8.702)
cp6_2010_02_15_00 -15.32 3.669 -4.177 3.05e-05 *** (-22.52, -8.13)
cp7_2010_06_07_00 22.99 3.572 6.436 1.44e-10 *** (15.99, 29.99)
cp8_2010_09_27_00 -19.22 3.189 -6.027 1.90e-09 *** (-25.47, -12.97)
cp9_2011_01_24_00 9.736 2.134 4.563 5.26e-06 *** (5.552, 13.92)
cp10_2011_09_05_00 1.313 1.875 0.7004 0.484 (-2.363, 4.989)
cp11_2012_01_02_00 -0.974 2.264 -0.4303 0.667 (-5.413, 3.465)
cp12_2012_04_23_00 -5.817 1.289 -4.513 6.67e-06 *** (-8.345, -3.29)
cp13_2013_04_01_00 4.068 0.4334 9.387 <2e-16 *** (3.219, 4.918)
cp14_2013_11_11_00 -2.268 0.2404 -9.435 <2e-16 *** (-2.739, -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 output = summary.get_coef_summary(
221 is_intercept=True,
222 is_trend=True,
223 is_seasonality=False,
224 is_interaction=False,
225 return_df=True # returns the filtered df
226 )
Out:
Pred_col Estimate Std. Err t value Pr(>|t|) sig. code 95%CI
Intercept 0.7656 0.01628 47.02 <2e-16 *** (0.7336, 0.7975)
ct1 -1.617 3.574 -0.4524 0.651 (-8.626, 5.391)
cp0_2008_03_31_00 -0.4259 5.62 -0.07578 0.940 (-11.45, 10.59)
cp1_2008_07_21_00 -10.14 4.849 -2.092 0.037 * (-19.65, -0.6345)
cp2_2008_11_10_00 15.7 4.422 3.551 3.90e-04 *** (7.032, 24.37)
cp3_2009_03_09_00 5.406 4.242 1.274 0.203 (-2.912, 13.72)
cp4_2009_06_29_00 -6.591 4.168 -1.581 0.114 (-14.76, 1.583)
cp5_2009_10_19_00 1.181 3.836 0.3079 0.758 (-6.34, 8.702)
cp6_2010_02_15_00 -15.32 3.669 -4.177 3.05e-05 *** (-22.52, -8.13)
cp7_2010_06_07_00 22.99 3.572 6.436 1.44e-10 *** (15.99, 29.99)
cp8_2010_09_27_00 -19.22 3.189 -6.027 1.90e-09 *** (-25.47, -12.97)
cp9_2011_01_24_00 9.736 2.134 4.563 5.26e-06 *** (5.552, 13.92)
cp10_2011_09_05_00 1.313 1.875 0.7004 0.484 (-2.363, 4.989)
cp11_2012_01_02_00 -0.974 2.264 -0.4303 0.667 (-5.413, 3.465)
cp12_2012_04_23_00 -5.817 1.289 -4.513 6.67e-06 *** (-8.345, -3.29)
cp13_2013_04_01_00 4.068 0.4334 9.387 <2e-16 *** (3.219, 4.918)
cp14_2013_11_11_00 -2.268 0.2404 -9.435 <2e-16 *** (-2.739, -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 37.993 seconds)