format="pdf", dpi=800) fig.savefig(os.path.join(baseline_working_directory, "Output", "ICML18_Figure5_Nile.png"), format="png", dpi=800) # Check that the figure has indeed been generated and report if os.path.isfile(os.path.join(baseline_working_directory, "Output", "ICML18_Figure5_Nile.pdf")): print("Figure 5 can be found in the Output directory") """STEP 4: Generate additional figures, if requested""" if save_extra_figures: # Plot the prediction error and variance fig_pe, ax_pe = plt.subplots() EvT.plot_prediction_error(river_height.reshape(T, 1, 1), indices=[0], show_var=True, show_MAP_CPs=True, up_to=250, ax=ax_pe) fig_pe.savefig(os.path.join(baseline_working_directory, "Output", "ICML18_ExtraFigure_Nile_PredError.pdf"), format="pdf", dpi=800) if os.path.isfile(os.path.join(baseline_working_directory, "Output", "ICML18_ExtraFigure_Nile_PredError.pdf")): print("Extra plot of the prediction error can be found in the Output directory") # Plot the model posterior fig_mp, ax_mp = plt.subplots() EvT.plot_model_posterior(indices=[0, 1, 2], log_format=False, up_to=150, plot_type="MAPVariance1_det", show_MAP_CPs=True, ax=ax_mp) fig_mp.savefig(os.path.join(baseline_working_directory, "Output", "ICML18_ExtraFigure_Nile_ModelPosterior.pdf"), format="pdf", dpi=800) if os.path.isfile(os.path.join(baseline_working_directory, "Output", "ICML18_ExtraFigure_Nile_ModelPosterior.pdf")): print("Extra plot of the model posterior can be found in the Output directory")
fig, ax_array = plt.subplots(num_subplots, sharex = True, gridspec_kw = {'height_ratios':height_ratio})#, #figsize = (12,5)) plt.subplots_adjust(hspace = .185, left = None, bottom = None, right = None, top = None) """plot raw data""" fig_1 = EvT.plot_raw_TS(data, indices=[0,2,4], custom_colors_series = custom_colors_series, ax = ax_array[0],xlab=None, ylabel_coords = ylabel_coords) #ax_array[0]) """Plot + save pics (4) prediction + error""" fig_2 = EvT.plot_prediction_error(show_var= True, data = data_original, indices = [0], custom_colors = ['black', 'darkgray'], ax=ax_array[1], time_range = np.linspace(1,T-2,T-2,dtype=int), aspect_ratio = 'auto', xlab = None, ylab = "PE", ylabel_coords = ylabel_coords) """Plot + save pictures: (3) model posteriors""" """Plot + save pictures: (2) Raw TS with MAP CPs""" #backconverter = tick/C2-C1 (backconv+C1)*C2 = tick C1, C2 = 100, 1 #raw_ticks = [pow(10, -18), pow(10, -15), pow(10, -13), pow(10, -11)] colorbar_ticks = None #[C2*(r+C1) for r in raw_ticks] fig_4 = EvT.plot_run_length_distr(mark_max=True,upper_limit=250, aspect_ratio='auto', C1=C1, C2=C2, time_range = np.linspace(1,T-2,T-2, dtype=int), CP_legend = True, CP_legend_fontsize = 8, CP_custom_legend_labels = ["AR(2)", "AR(3)", "VAR4(2)"],
trim_type="keep_K", threshold=200, training_period=25, #i.e., we let 2 years pass before MSE computed notifications=1500, save_performance_indicators=True) detector.run() """Store results + real CPs into EvaluationTool obj""" EvT = EvaluationTool() EvT.build_EvaluationTool_via_run_detector(detector) """plot transformed data""" fig = EvT.plot_raw_TS(data.reshape(T, 1)) """plot prediction error""" fig = EvT.plot_prediction_error(data, indices=[0], print_plt=True, time_range=np.linspace(2 * 365, T - upper_AR - 1, T - upper_AR - 1 - 2 * 365, dtype=int)) """plot predictions themselves""" fig = EvT.plot_predictions(indices=[0], print_plt=True, legend=False, legend_labels=None, legend_position=None, time_range=None, show_var=False, show_CPs=True) plt.show()