@@ -60,7 +60,7 @@ ax.scatter(df_test.ds, df_test.y, marker="o", color="w", edgecolor="k", label="T
6060
6161
6262
63- Python: <matplotlib.collections.PathCollection object at 0x7367187bbe30 >
63+ Python: <matplotlib.collections.PathCollection object at 0x7ddc363cdb80 >
6464
6565
6666
@@ -109,7 +109,7 @@ ax.scatter(df_test.ds, df_test.y, marker="o", color="w", edgecolor="k", label="T
109109
110110
111111
112- Python: <matplotlib.collections.PathCollection object at 0x7367183731a0 >
112+ Python: <matplotlib.collections.PathCollection object at 0x7ddc35e42880 >
113113
114114
115115
@@ -628,7 +628,7 @@ for (ax, m, f) in zip(axes, [model_lin, model_per, model_ge], [forecasts_lin, fo
628628end
629629axes[0 ]. set_title (" STRUCTURE: LIN" )
630630axes[1 ]. set_title (" STRUCTURE: PER" )
631- axes[2 ]. set_title (" STRUCTURE: GE" )
631+ axes[2 ]. set_title (" STRUCTURE: GE" );
632632```
633633
634634
@@ -637,12 +637,6 @@ axes[2].set_title("STRUCTURE: GE")
637637
638638
639639
640-
641-
642-
643-
644-
645-
646640## Sum-of-Products Decomposition
647641
648642An third approach to decomposing kernels is using [ ` AutoGP.split_kernel_sop ` ] ( @ref ) , which is based on a sum-of-products decomposition of kernels.
@@ -724,18 +718,20 @@ nrows = AutoGP.num_particles(model)
724718fig, axes = PythonPlot. subplots (ncols= 3 , nrows= nrows, figsize= (26 ,5 * nrows))
725719for particle= 1 : AutoGP. num_particles (model)
726720 f = forecasts_sum[forecasts_sum. particle .== particle,:]
727- for (component, ax) in zip (0 : 2 , axes[particle- 1 ])
721+ for (component, ax) in zip ([ 0 , 2 , 1 ] , axes[particle- 1 ])
728722 subdf = f[f. component .== component,:]
729723 ax. plot (subdf[! ," ds" ], subdf[! ," y_mean" ], color= " k" , linewidth= 1 )
730724 ax. fill_between (subdf. ds, subdf[! ," y_0.025" ], subdf[! ," y_0.975" ]; color= " tab:blue" , alpha= 0.5 )
731- ax. scatter (df_train. ds, df_train. y, marker= " o" , color= " k" , label= " Observed Data" )
732- ax. scatter (df_test. ds, df_test. y, marker= " o" , color= " w" , edgecolor= " k" , label= " Test Data" )
725+ if component in [0 ,2 ]
726+ ax. scatter (df_train. ds, df_train. y, marker= " o" , color= " k" , label= " Observed Data" )
727+ ax. scatter (df_test. ds, df_test. y, marker= " o" , color= " w" , edgecolor= " k" , label= " Test Data" )
728+ ax. set_ylim ([5000 , 7500 ])
729+ end
733730 w = @sprintf (" %1.2f" , maximum (subdf. weight))
734731 ax. set_title (" Particle $(particle) - Component $(title[component+ 1 ]) - Weight $(w) " )
735- ax. set_ylim ([5000 , 7500 ])
736732 end
737733end
738- fig. savefig (" forecasts-joint.png" , dpi= 150 )
734+ fig. savefig (" forecasts-joint.png" , dpi= 150 );
739735```
740736
741737
@@ -744,27 +740,24 @@ fig.savefig("forecasts-joint.png", dpi=150)
744740
745741
746742
747-
748-
749-
750-
751-
752-
753743Using [ ` AutoGP.GP.predict_mvn_sum ` ] ( @ref ) gives the overall mixture of Gaussians.
754744
755745
756746``` julia
757747ds_probe = vcat (df_train. ds, df_test. ds)
758748mvn, indexes = AutoGP. predict_mvn_sum (model, ds_probe, AutoGP. GP. Periodic);
759749
760- overall_predictions = mean (mvn)[indexes. Y]
761- seasonal_predictions = mean (mvn)[indexes. F[1 ]]
762- nonseasonal_predictions = mean (mvn)[indexes. F[2 ]]
763- fig, ax = PythonPlot. subplots (figsize= (10 ,6 ))
764- ax. plot (ds_probe, seasonal_predictions, marker= " ." , color= " k" )
765- ax. plot (ds_probe, nonseasonal_predictions, marker= " ." , color= " k" )
766- ax. scatter (df_train. ds, df_train. y, marker= " ." )
767- ax. scatter (df_test. ds, df_test. y, marker= " o" , edgecolor= " k" , facecolor= " w" )
750+ overall_predictions = mean (mvn. components[1 ])[indexes. Y]
751+ seasonal_predictions = mean (mvn. components[1 ])[indexes. F[1 ]]
752+ nonseasonal_predictions = mean (mvn. components[1 ])[indexes. F[2 ]]
753+
754+ fig, ax = PythonPlot. subplots (figsize= (18 ,6 ), ncols= 2 )
755+ ax[0 ]. plot (ds_probe, nonseasonal_predictions, marker= " ." , color= " k" )
756+ ax[0 ]. plot (ds_probe, nonseasonal_predictions .+ seasonal_predictions , marker= " ." , color= " k" )
757+ ax[0 ]. scatter (df_train. ds, df_train. y, marker= " ." )
758+ ax[0 ]. scatter (df_test. ds, df_test. y, marker= " o" , edgecolor= " k" , facecolor= " w" );
759+
760+ ax[1 ]. plot (ds_probe, seasonal_predictions, marker= " ." , color= " k" )
768761```
769762
770763
@@ -776,5 +769,11 @@ ax.scatter(df_test.ds, df_test.y, marker="o", edgecolor="k", facecolor="w")
776769
777770
778771
772+ Python: [<matplotlib.lines.Line2D object at 0x7ddb977b57c0>]
773+
779774
780775
776+
777+ ``` julia
778+
779+ ```
0 commit comments