コード例 #1
0
EvT.plot_run_length_distr(
    buffer=0,
    show_MAP_CPs=False,
    mark_median=False,
    mark_max=True,
    upper_limit=1000,
    print_colorbar=True,
    colorbar_location='bottom',
    log_format=True,
    aspect_ratio='auto',
    C1=0,
    C2=1,
    time_range=np.linspace(1, T - 2, T - 2, dtype=int),
    start=1,
    stop=T,
    all_dates=None,
    #event_time_list=[715 ],
    #label_list=["nilometer"], space_to_colorbar = 0.52,
    custom_colors=["blue", "blue"] * 30,
    custom_linestyles=["solid"] * 30,
    custom_linewidth=3,
    #arrow_colors= ["black"],
    #number_fontsize = 14,
    #arrow_length = 135,
    #arrow_thickness = 3.0,
    xlab_fontsize=14,
    ylab_fontsize=14,
    #arrows_setleft_indices = [0],
    #arrows_setleft_by = [50],
    #zero_distance = 0.0,
    ax=ax_array[1],
    figure=fig,
    no_transform=True,
    date_instructions_formatter=None,
    date_instructions_locator=None,
    ylabel_coords=ylabel_coords,
    xlab="observation number",
    arrow_distance=25)
コード例 #2
0
 EvTKL.plot_run_length_distr(buffer=0, show_MAP_CPs = True, 
                                    mark_median = False, 
     mark_max = True, upper_limit = 1400, print_colorbar = True, 
     colorbar_location= 'bottom',
     space_to_colorbar = 0.5,
     log_format = False, aspect_ratio = 'auto', 
     #C1=0,C2=700, 
     time_range = np.linspace(1,
                              T-2, 
                              T-2, dtype=int), 
     start = 1, stop = T, 
     all_dates = None, 
     #event_time_list=[715 ],
     #label_list=["nilometer"], space_to_colorbar = 0.52,
     custom_colors = ["blue", "blue"] * 30, 
     custom_linestyles = [":"]*30,
     custom_linewidth = 1.5,
     #arrow_colors= ["black"],
     #number_fontsize = 14,
     #arrow_length = 135,
     #arrow_thickness = 3.0,
     xlab_fontsize =12,
     ylab_fontsize = 12, 
     #arrows_setleft_indices = [0],
     #arrows_setleft_by = [50],
     #zero_distance = 0.0,
     ax = ax_arrays[1][0], figure = fig,
     no_transform = True,
     date_instructions_formatter = None, 
     date_instructions_locator = None,
     ylabel_coords = ylabel_coords,
     xlab = "Time",
     #ylab="",
     arrow_distance = 25,
     mark_max_linewidth = 0.8)
コード例 #3
0
_, myfig=EvT.plot_run_length_distr(buffer=0, show_MAP_CPs = True, mark_median = False, 
    mark_max = True, upper_limit = 115, enforce_upper_limit=True, print_colorbar = True, 
    colorbar_location= 'top',log_format = True, aspect_ratio = 'auto', 
    C1=700,C2=1, 
    time_range = np.linspace(start_comparison - start_test,
                             stop_comparison - start_test - 2, 
                             stop_comparison-start_comparison-2, dtype=int), 
    #start=start, stop = stop, 
    all_dates = all_dates,
    event_time_list=event_time_list, 
    label_list=label_list, space_to_colorbar = 0.9,
    custom_colors = custom_colors, #["blue"]*len(event_time_list),
    custom_linestyles = ["solid"]*len(event_time_list),
    custom_linewidth = 3,
    arrow_colors= arrow_color_list,
    number_fontsize = 18,
    arrow_length = 13, #paper: arrow-length = 13 poster arrow-length = 27
    arrow_thickness = 4.0,
    arrows_setleft_indices = [3,13,14,15, 20, 21],
    #paper: arrows_setleft_indices = [3,13,14,15, 20, 21],
    #poster: arrows_setleft_indices = [3,13,14,15,16,17,18, 20, 21],
    #poster: arrows_setleft_by = [datetime.timedelta(days = 3),
    #                    datetime.timedelta(days=15),datetime.timedelta(days=8), 
    #                     -datetime.timedelta(days = 1),
    #                     -datetime.timedelta(days=6),
    #                     -datetime.timedelta(days=9),
    #                     datetime.timedelta(days = 3),
    #                     datetime.timedelta(days=9), datetime.timedelta(days=1)],
    #paper: 
    arrows_setleft_by = [datetime.timedelta(days = 3),
                        datetime.timedelta(days=7),datetime.timedelta(days=4), 
                         -datetime.timedelta(days = 1),
                         datetime.timedelta(days=9), datetime.timedelta(days=1)],
    zero_distance = datetime.timedelta(days=0),
    xlab_fontsize =14,
    ylab_fontsize = 14, 
    xticks_fontsize = 12,
    yticks_fontsize = 12,
    ax = ax, figure = fig,
    xlab = "Year-Month")
コード例 #4
0
                                  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)"],
                                  additional_legend_labels = ["VAR8(1)"],
                                  additional_legend_colors = ["blue"],
                                  CP_exclude_indices = [7], #just obscures view
                                  custom_colors = custom_colors_models,
                                  custom_linestyles =custom_linestyles, 
                                  ax = ax_array[-1], figure = fig, space_to_colorbar = 0.275,
                                  orientation = 'horizontal',
                                  xlab=None, colorbar_location = "bottom",
                                  ylabel_coords = ylabel_coords,
                                  colorbar_ticks_num = 1)

if one_model_posterior_plot:
#custom_colors = ['purple', 'orange', 'red', 'green']
    fig_3 = EvT.plot_model_posterior(indices= [1,2,5,6],#relevant_models.append(30), 
                                     plot_type = "trace",
                                     y_axis_labels = ["mod1", "mod2", "mod3"],
                                     log_format=False, aspect = 'auto',
                                     show_MAP_CPs = False,
コード例 #5
0
                    if not shortened:
                        EvT.store_results_to_HD(results_path)

                    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.close(fig)
                    fig = EvT.plot_run_length_distr(print_plt=True,
                                                    time_range=None,
                                                    show_MAP_CPs=True,
                                                    show_real_CPs=False,
                                                    mark_median=False,
                                                    log_format=True,
                                                    CP_legend=False,
                                                    buffer=50)
                    plt.close(fig)

                    plt.plot(
                        np.linspace(1, len(detector.model_universe[0].a_list),
                                    len(detector.model_universe[0].a_list)),
                        np.array(detector.model_universe[0].a_list))
                    plt.plot(
                        np.linspace(1, len(detector.model_universe[0].b_list),
                                    len(detector.model_universe[0].b_list)),
                        np.array(detector.model_universe[0].b_list))

                    print("MSE", np.sum(np.mean(detector.MSE, axis=0)),
コード例 #6
0
print("convergence diagnostics for on-line hyperparameter opt:")
plt.plot(np.linspace(1,len(detector.model_universe[0].a_list), 
                     len(detector.model_universe[0].a_list)), 
         np.array(detector.model_universe[0].a_list))
plt.plot(np.linspace(1,len(detector.model_universe[0].b_list),
                     len(detector.model_universe[0].b_list)), 
         np.array(detector.model_universe[0].b_list))

fig = EvT.plot_run_length_distr(
    time_range = np.linspace(1,
                             T-max(upper_VAR, upper_AR)-1,
                             T-max(upper_VAR, upper_AR)-1,
                             dtype=int),
    print_plt = True, 
    C1=10,C2=10, #scale the rld at plotting time to make it visibly discernible
    show_MAP_CPs = True, 
    show_real_CPs = False,
    mark_median = False, 
    log_format = True,
    CP_legend = False, 
    colorbar_location= 'bottom',
    space_to_colorbar = 0.52,
    buffer = 50)

plt.show()

print("************PRED MSE + NLL AS IN PAPER************")
print("MSE", np.sum(np.mean(detector.MSE, axis=0)))
print("NLL", np.mean(detector.negative_log_likelihood))
print("**************************************************")
コード例 #7
0
EvT.plot_run_length_distr(
    buffer=0,
    show_MAP_CPs=True,
    mark_median=False,
    mark_max=True,
    upper_limit=T - 2 - minus,
    print_colorbar=True,
    colorbar_location='bottom',
    log_format=True,
    aspect_ratio='auto',
    #C1=1,C2=0,
    time_range=np.linspace(1, T - 2 - minus, T - 2 - minus, dtype=int),
    #start = 622 + 2, stop = 1284-minus, #start=start, stop = stop,
    all_dates=None,  #all_dates,
    event_time_list=outlier_locations +
    CP_locations,  #datetime.date(715,1,1)], 
    label_list=["o"] * len(outlier_locations) + ["cp"] * len(CP_locations),
    space_to_colorbar=0.52,
    custom_colors=["blue", "blue"] * 100,  #["blue"]*len(event_time_list),
    custom_linestyles=["solid"] * 3,
    custom_linewidth=3,
    arrow_colors=["black"] * len(outlier_locations) +
    ["orange"] * len(CP_locations),
    number_fontsize=14,
    arrow_length=135,
    arrow_thickness=3.0,
    xlab_fontsize=14,
    ylab_fontsize=14,
    arrows_setleft_indices=[0],
    arrows_setleft_by=[50],
    zero_distance=0.0,
    ax=None,
    figure=None,
    no_transform=True,
    date_instructions_formatter=None,  #yearsFmt,
    date_instructions_locator=None,
    #ylabel_coords = ylabel_coords,
    xlab="Year",
    arrow_distance=25)
 EvTKL.plot_run_length_distr(
     buffer=0,
     show_MAP_CPs=show_CPs_in_rld_KL,
     mark_median=False,
     mark_max=True,
     upper_limit=70,
     print_colorbar=False,
     colorbar_location=None,
     space_to_colorbar=0.5,
     log_format=False,
     aspect_ratio='auto',
     #C1=0,C2=700,
     time_range=time_range,  #np.linspace(1,
     #           T-2,
     #           T-2, dtype=int),
     #start = 1, stop = T,
     all_dates=all_dates,
     #event_time_list=[715 ],
     #label_list=["nilometer"], space_to_colorbar = 0.52,
     custom_colors=[KL_CP_color] * 30,
     custom_linestyles=[CP_style_KL] * 30,
     custom_linewidth=CP_linewidth_KL,
     CP_transparence=CP_transparence_KL,
     xlab_fontsize=12,
     ylab_fontsize=12,
     ax=ax_array[1],
     figure=fig,
     no_transform=True,
     date_instructions_formatter=None,
     date_instructions_locator=None,
     ylabel_coords=ylabel_coords,
     xlab="Time",
     ylab="run length",
     arrow_distance=25,
     mark_max_linewidth=max_width,
     mark_max_color=max_color_KL)
コード例 #9
0

EvTDPD.plot_run_length_distr(buffer=0, show_MAP_CPs = show_CPs_in_rld, 
    mark_median = False, 
    mark_max = True, 
    upper_limit = 1300, 
    print_colorbar = False, 
    colorbar_location= None,
    xlab = "",
    ylab = "", 
    log_format = False, aspect_ratio = 'auto', 
    time_range = np.linspace(1,
                             T-2, 
                             T-2, dtype=int), 
    start = 1, stop = T, 
    all_dates = None, 
    custom_colors = [DPD_CP_color] * 30, 
    custom_linestyles = [CP_style_DPD]*30,
    custom_linewidth = CP_linewidth_DPD,
    xlab_fontsize = xlabsize,
    ylab_fontsize = ylabsize, 
    xticks_fontsize = ticksize,
    yticks_fontsize = ticksize,
    ax = ax_array[1], figure = fig,
    no_transform = True,
    date_instructions_formatter = None, 
    date_instructions_locator = None,
    arrow_distance = 25,
    mark_max_linewidth = max_width,
    mark_max_color = max_color_DPD)