def run_experiments(times, datasizes, observations, epsilon, delta, prior): data = [] errors = [[], [], [], [], []] for i in range(len(datasizes)): observation = observations[i] Bayesian_Model = BayesInferwithDirPrior(prior, sum(observation), epsilon, delta) Bayesian_Model._set_observation(observation) print("start" + str(observation)) Bayesian_Model._experiments(times) print("finished" + str(observation)) for i in range(5): data.append(Bayesian_Model._accuracy[Bayesian_Model._keys[i]]) plot_error_box(data, "Different Data Sets", ["bike", "cryotherapy", "immunotherapy"], "Experiments on Real Data", [ r'Alg 1 - $\mathsf{LSDim}$ (sensitivity = 2.0)', r'Alg 2 - $\mathsf{LSHist}$ (sensitivity = 1.0)', r'Alg 5 - $\mathsf{EHDS}$ ', r"Alg 3 - $\mathsf{EHD}$", r"Alg 4 - $\mathsf{EHDL}$" ], ["skyblue", "navy", "coral", "crimson", "blueviolet"]) return
def accuracy_VS_prior(sample_size, epsilon, delta, priors, observation): data = [] mean_error = [[], [], [], [], []] for prior in priors: Bayesian_Model = BayesInferwithDirPrior(prior, sample_size, epsilon, delta) Bayesian_Model._set_observation(observation) Bayesian_Model._experiments(1000) data.append(Bayesian_Model._accuracy[Bayesian_Model._keys[3]]) data.append(Bayesian_Model._accuracy[Bayesian_Model._keys[0]]) data.append(Bayesian_Model._accuracy[Bayesian_Model._keys[4]]) mean_error[0].append( Bayesian_Model._accuracy_mean[Bayesian_Model._keys[3]]) mean_error[1].append( Bayesian_Model._accuracy_mean[Bayesian_Model._keys[0]]) mean_error[2].append( Bayesian_Model._accuracy_mean[Bayesian_Model._keys[4]]) print('Accuracy / observation: ' + str(observation) + ", delta: " + str(delta) + ", epsilon:" + str(epsilon)) plot_error_box(data, r"Different Priors on $\theta$", [r"$\mathsf{beta}$" + str(i._alphas) for i in priors], "Accuracy VS. Prior Distribution", [ r'$\mathcal{M}_{\mathcal{H}}$', "LapMech (sensitivity = 1)", "LapMech (sensitivity = 2)" ], ['navy', 'red', 'green']) return
def ss_exponentiate_component_study(prior, sample_size, epsilon, delta, percentage): Bayesian_Model = BayesInferwithDirPrior(prior, sample_size, epsilon, delta) observation = [sample_size * i for i in percentage] Bayesian_Model._set_observation(observation) Bayesian_Model._set_candidate_scores() xstick = [ str((c._minus(Bayesian_Model._prior))._alphas) for c in Bayesian_Model._candidates ] # print [c._alphas for c in Bayesian_Model._candidates] beta = math.log(1 - epsilon / (2.0 * math.log(delta / (2.0 * (sample_size))))) # y=[Hamming_Distance(Bayesian_Model._observation_counts, r._alphas) for r in Bayesian_Model._candidates] # print y y = [ math.exp(-beta * Hamming_Distance(observation, r._alphas)) for r in Bayesian_Model._candidates ] scatter_plot( y, xstick, 'Exponentiate Component of Smooth Sensitivity w.r.t. x :' + str([sample_size * i for i in percentage]) + r'; $\epsilon:$' + str(epsilon) + r'; $\delta:$' + str(delta), r"$e^{- \gamma *d(x,x')}$") return
def smooth_sensitivity_study(prior, sample_size, epsilon, delta, percentage): Bayesian_Model = BayesInferwithDirPrior(prior, sample_size, epsilon, delta) observation = [sample_size * i for i in percentage] Bayesian_Model._set_observation([sample_size * i for i in percentage]) Bayesian_Model._set_candidate_scores() Bayesian_Model._set_LS_Candidates() xstick = [ str((r._minus(Bayesian_Model._prior))._alphas) for r in Bayesian_Model._candidates ] beta = 0.00000001 y = [ Bayesian_Model._LS_Candidates[r] * math.exp(-beta * Hamming_Distance(observation, r._alphas)) for r in Bayesian_Model._candidates ] scatter_plot( y, xstick, 'Smooth Sensitivity Study w.r.t. x :' + str([sample_size * i for i in percentage]) + r'; $\epsilon = $' + str(epsilon) + r'; $\delta:$' + str(delta), r"$\Delta_l(H(BI(x'),-))e^{- \gamma *d(x,x')}$")
def accuracy_VS_gamma(epsilon, prior, data, gammas): mean_error = [[]] for g in gammas: Bayesian_Model = BayesInferwithDirPrior(prior, sum(data), epsilon, 0.1, g) Bayesian_Model._set_observation(data) print("start" + str(g)) Bayesian_Model._experiments(1000) print("finished" + str(g)) mean_error[0].append( Bayesian_Model._accuracy_mean[Bayesian_Model._keys[3]]) print('Accuracy / prior: ' + str(prior._alphas) + ", delta: " + str(delta) + ", epsilon:" + str(epsilon)) # print mean_error plot_mean_error(gammas, mean_error, gammas, "Different Gammas for Smooth Sensitivity", [r"$\mathsf{EHDS}$"], "") # plot_error_box(data,"Different Datasizes",datasizes,"Accuracy VS. Data Size", # [r'$\mathcal{M}^{B}_{\mathcal{H}}$',"LapMech (sensitivity = 2)", "LapMech (sensitivity = 3)"], # ['lightblue', 'navy', 'red']) return
def probability_values(datasize,epsilon,delta,prior,observation, mech): Bayesian_Model = BayesInferwithDirPrior(prior, datasize, epsilon, delta) Bayesian_Model._set_observation(observation) Bayesian_Model._set_candidate_scores() Bayesian_Model._set_local_sensitivities() if(mech == r'Alg 3 - $\mathsf{EHD}$'): Bayesian_Model._set_up_exp_mech_with_GS() elif(mech == r'Alg 4 - $\mathsf{EHDL}$'): Bayesian_Model._set_up_exp_mech_with_LS() elif(mech == r'Alg 5 - $\mathsf{EHDS}$'): Bayesian_Model._set_up_exp_mech_with_gamma_SS() probabilities_exp = {} for i in range(len(Bayesian_Model._candidates)): z = Bayesian_Model._candidates[i] if(mech == r'Alg 3 - $\mathsf{EHD}$'): probabilities_exp[str(z._alphas)] = Bayesian_Model._GS_probabilities[i] elif(mech == r'Alg 4 - $\mathsf{EHDL}$'): probabilities_exp[str(z._alphas)] = Bayesian_Model._LS_probabilities[i] elif(mech == r'Alg 5 - $\mathsf{EHDS}$'): probabilities_exp[str(z._alphas)] = Bayesian_Model._gamma_SS_probabilities[i] return probabilities_exp
def exp_distribution_over_candidates(dataobs, prior, epsilon, mech): n = sum(dataobs) Bayesian_Model = BayesInferwithDirPrior(prior, n, epsilon) Bayesian_Model._set_observation(dataobs) Bayesian_Model._set_candidate_scores() Bayesian_Model._set_local_sensitivities() if mech == "exp": Bayesian_Model._set_up_exp_mech_with_GS() elif mech == "gamma": Bayesian_Model._set_up_exp_mech_with_gamma_SS() exp_prob = {} for i in range(len(Bayesian_Model._candidates)): z = Bayesian_Model._candidates[i]._pointwise_sub(prior) if mech == "exp": exp_prob[list2key(z._alphas)] = Bayesian_Model._GS_probabilities[i] elif mech == "gamma": exp_prob[list2key( z._alphas)] = Bayesian_Model._gamma_SS_probabilities[i] # print exp_prob return exp_prob
def get_steps_opt(dataobs, prior, epsilon): n = sum(dataobs) Bayesian_Model = BayesInferwithDirPrior(prior, n, epsilon) Bayesian_Model._set_observation(dataobs) Bayesian_Model._set_candidate_scores() cpara = [] for c in Bayesian_Model._candidates: cpara.append(list2key(c._minus(prior)._alphas)) return cpara
def ls_scaled_by_eps(n, prior, epsilon): Bayesian_Model = BayesInferwithDirPrior(prior, n, epsilon) Bayesian_Model._set_observation(gen_dataset_rand(len(prior._alphas), n)) Bayesian_Model._set_candidate_scores() Bayesian_Model._set_local_sensitivities() ls = [] xstick = [] for c in Bayesian_Model._candidates: ls.append(Bayesian_Model._LS_Candidates[c] / epsilon) xstick.append(c._alphas) return ls, xstick
def expect_errors_Lap(n, prior, epsilon): Bayesian_Model = BayesInferwithDirPrior(prior, n, epsilon) Bayesian_Model._set_observation(gen_dataset_rand(len(prior._alphas), n)) Bayesian_Model._set_candidate_scores() candidates = Bayesian_Model._candidates expecterror = [] xstick = [] for c in candidates: expecterror.append(expect_error_Lap(c, prior, epsilon)) xstick.append(str(c._alphas)) return expecterror, xstick
def sensitivities(datasets, prior, beta, delta, label): sensitivities = [] for dataset in datasets: Bayesian_Model = BayesInferwithDirPrior(prior, sum(dataset), epsilon, delta) Bayesian_Model._set_observation(dataset) Bayesian_Model._set_candidate_scores() Bayesian_Model._set_local_sensitivities() candidates = Bayesian_Model._candidates for c in candidates: ######################################################################################################################### #GET THE ADJACENT DATA SET OF DATA SET C if (label == r"Local Sensitivity ($LS(x')$)"): sensitivities.append(Bayesian_Model._LS_Candidates[c]) elif (label == r"Our Sensitivity ($\frac{1}{\frac{1}{LS(x')} +\gamma \cdot d(x,x')}$)"): sensitivities.append((1.0 / (1.0/Bayesian_Model._LS_Candidates[c] + 1.0 * Hamming_Distance(Bayesian_Model._observation_counts, [c._alphas[i] - Bayesian_Model._prior._alphas[i] for i in range(Bayesian_Model._prior._size)])))) return sensitivities, [list(numpy.array(c._alphas) - 1) for c in candidates]
def decomposed_probability_values(datasize,epsilon,delta,prior,observation): Bayesian_Model = BayesInferwithDirPrior(prior, datasize, epsilon, delta) Bayesian_Model._set_observation(observation) Bayesian_Model._set_candidate_scores() Bayesian_Model._set_local_sensitivities() nomalizer = Bayesian_Model._set_up_exp_mech_with_gamma_SS() probabilities_exp = {} for i in range(len(Bayesian_Model._candidates)): z = Bayesian_Model._candidates[i] probabilities_exp[str(z._alphas)] = nomalizer * Bayesian_Model._gamma_SS_probabilities[i] return nomalizer, probabilities_exp
def exp_smooth_theoryProb(dataobs, prior, epsilon, gamma): n = sum(dataobs) Bayesian_Model = BayesInferwithDirPrior(prior, n, epsilon, 0.1, gamma) Bayesian_Model._set_observation(dataobs) Bayesian_Model._set_candidate_scores() Bayesian_Model._set_local_sensitivities() Bayesian_Model._gamma = gamma Bayesian_Model._set_up_exp_mech_with_gamma_SS() exp_prob = {} for i in range(len(Bayesian_Model._candidates)): z = Bayesian_Model._candidates[i]._pointwise_sub(prior) exp_prob[list2key( z._alphas)] = Bayesian_Model._gamma_SS_probabilities[i] return exp_prob
def smooth_sensitivity_study2(prior, sample_size, epsilon, delta, percentage): Bayesian_Model = BayesInferwithDirPrior(prior, sample_size, epsilon, delta) observation = [sample_size * i for i in percentage] Bayesian_Model._set_observation([sample_size * i for i in percentage]) Bayesian_Model._set_candidate_scores() Bayesian_Model._set_LS_Candidates() x = [(c._minus(Bayesian_Model._prior)) for c in Bayesian_Model._candidates] beta = 0.001 # math.log(1 - epsilon / (2.0 * math.log(delta / (2.0 * (sample_size))))) max_value_list = [] xstick = [ str((r._minus(Bayesian_Model._prior))._alphas) for r in Bayesian_Model._candidates ] for t in x: Bayesian_Model._set_observation(t._alphas) # Bayesian_Model._set_candidate_scores() # Bayesian_Model._set_LS_Candidates() max_value = 0.0 max_y = '' # max_y_list = [] for r in Bayesian_Model._candidates: temp = Bayesian_Model._LS_Candidates[r] * math.exp( -beta * Hamming_Distance(t._alphas, r._alphas)) if max_value < temp: max_y = r._alphas max_value = temp # for r in Bayesian_Model._candidates: # temp = Bayesian_Model._LS_Candidates[r] * math.exp(- beta * Hamming_Distance(observation, r._alphas)) # if max_value == temp: # max_y_list.append(str(r._alphas)) max_value_list.append(max_value) print "when data set x = " + str( t._alphas) + ", smooth sensitivity: S(" + str( t._alphas) + ") = " + str(max_value) scatter_plot( y, xstick, 'Smooth Sensitivity Given Size' + str(sample_size), )
def sensitivities_2(datasizes, prior, beta, delta, label, gamma=1.0): sensitivities = [] candidates = [] for datasize in datasizes: Bayesian_Model = BayesInferwithDirPrior(prior, datasize, epsilon, delta, gamma) Bayesian_Model._set_observation(gen_dataset([0.5,0.5],datasize)) Bayesian_Model._set_candidate_scores() Bayesian_Model._set_local_sensitivities() candidates = [list(numpy.array(c._alphas) - 1) for c in Bayesian_Model._candidates] if(label == r"Local Sensitivity ($LS(x)$)"): for c in Bayesian_Model._candidates: sensitivities.append(Bayesian_Model._LS_Candidates[c]) elif(label == r"Our Sensitivity ($\max_{x'}(\frac{1}{\frac{1}{LS(x')} +\gamma \cdot d(x,x')})$)"): for c in candidates: Bayesian_Model._set_observation(c) Bayesian_Model._set_up_exp_mech_with_LS() Bayesian_Model._set_up_exp_mech_with_gamma_SS() sensitivities.append(Bayesian_Model._gamma_SS) return sensitivities, candidates
def accuracy_VS_datasize(epsilons, delta, prior, observation, datasize): data = [] mean_error = [[], []] for e in epsilons: Bayesian_Model = BayesInferwithDirPrior(prior, sum(observation), e, delta, 0.2) Bayesian_Model._set_observation(observation) print("start" + str(observation)) Bayesian_Model._experiments(1000) print("finished" + str(observation)) for j in range(len(mean_error)): mean_error[j].append( Bayesian_Model._accuracy_mean[Bayesian_Model._keys[j]]) plot_mean_error(epsilons, mean_error, [round(e, 2) for e in epsilons], "Different Datasizes", [r"$Laplace Noise$", r"$Geomoetric Noise$"], "") return
def ss_ls_component_study(prior, sample_size, epsilon, delta, percentage): Bayesian_Model = BayesInferwithDirPrior(prior, sample_size, epsilon, delta) observation = [sample_size * i for i in percentage] Bayesian_Model._set_observation([sample_size * i for i in percentage]) Bayesian_Model._set_candidate_scores() Bayesian_Model._set_LS_Candidates() xstick = [str(c._alphas) for c in Bayesian_Model._candidates] beta = math.log(1 - epsilon / (2.0 * math.log(delta / (2.0 * (sample_size))))) y = [ 1.0 / ((1 - Bayesian_Model._LS_Candidates[r]**2)) for r in Bayesian_Model._candidates ] print abs(y[2] - y[1]) scatter_plot(y, xstick, "", r"$\frac{1}{LS((\alpha, 100 - \alpha))}$") return
def accuracy_VS_prior_mean(sample_size, epsilon, delta, priors, observations): data = [] xlabel = [] for prior in priors: for observation in observations: Bayesian_Model = BayesInferwithDirPrior(prior, sample_size, epsilon, delta) Bayesian_Model._set_observation(observation) Bayesian_Model._experiments(300) data.append(Bayesian_Model._accuracy[Bayesian_Model._keys[3]]) data.append(Bayesian_Model._accuracy[Bayesian_Model._keys[0]]) xstick.append( str(prior._alphas) + ", data:" + str(observation) + "/ExpMech") xstick.append( str(prior._alphas) + ", data:" + str(observation) + "/Laplace") plot_error_box(data, "Different Prior Distributions", xstick, "Accuracy VS. Prior Distribution") return
def accuracy_VS_dimension(sample_sizes, epsilon, delta): data = [] xstick = [] for n in sample_sizes: for d in range(2, 5): observation = [n for i in range(d)] prior = Dir([1 for i in range(d)]) Bayesian_Model = BayesInferwithDirPrior(prior, n * d, epsilon, delta) Bayesian_Model._set_observation(observation) Bayesian_Model._experiments(500) data.append(Bayesian_Model._accuracy[Bayesian_Model._keys[3]]) data.append(Bayesian_Model._accuracy[Bayesian_Model._keys[0]]) xstick.append(str(observation) + "/ExpMech") xstick.append(str(observation) + "/Laplace") plot_error_box(data, "Different Prior Distributions", xstick, "Accuracy VS. Prior Distribution") return
def accuracy_VS_datasize(epsilon, delta, prior, observations, datasizes): data = [] mean_error = [[], []] for i in range(len(datasizes)): observation = observations[i] Bayesian_Model = BayesInferwithDirPrior(prior, sum(observation), epsilon, delta, 0.2) Bayesian_Model._set_observation(observation) print("start" + str(observation)) Bayesian_Model._experiments(1000) print("finished" + str(observation)) for j in range(len(mean_error)): mean_error[j].append( Bayesian_Model._accuracy_mean[Bayesian_Model._keys[j]]) print('Accuracy / prior: ' + str(prior._alphas) + ", delta: " + str(delta) + ", epsilon:" + str(epsilon)) plot_mean_error(datasizes, mean_error, datasizes, "Different Datasizes", [r"$Laplace Noise$", r"$Geomoetric Noise$"], "") return
def accuracy_VS_mean(sample_size, epsilon, delta, prior): data = [] xstick = [] temp = BayesInferwithDirPrior(prior, sample_size, epsilon, delta) temp._set_candidate_scores() observations = temp._candidates for i in range(len(observations)): observations[i]._minus(prior) for observation in observations: Bayesian_Model = BayesInferwithDirPrior(prior, sample_size, epsilon, delta) Bayesian_Model._set_observation(observation._alphas) Bayesian_Model._experiments(500) data.append(Bayesian_Model._accuracy[Bayesian_Model._keys[3]]) data.append(Bayesian_Model._accuracy[Bayesian_Model._keys[0]]) xstick.append(str(observation._alphas) + "/ExpMech") xstick.append(str(observation._alphas) + "/Laplace") plot_error_box(data, "Different Prior Distributions", xstick, "Accuracy VS. Prior Distribution") return
def accuracy_VS_datasize(epsilon, delta, prior, observations, datasizes): data = [] mean_error = [[], [], [], [], [], []] for i in range(len(datasizes)): observation = observations[i] Bayesian_Model = BayesInferwithDirPrior(prior, sum(observation), epsilon, delta, 0.2) Bayesian_Model._set_observation(observation) print("start" + str(observation)) Bayesian_Model._experiments(500) print("finished" + str(observation)) for j in range(len(mean_error)): mean_error[j].append( Bayesian_Model._accuracy_mean[Bayesian_Model._keys[j]]) # data.append(Bayesian_Model._accuracy[Bayesian_Model._keys[3]]) # data.append(Bayesian_Model._accuracy[Bayesian_Model._keys[0]]) # data.append(Bayesian_Model._accuracy[Bayesian_Model._keys[4]]) # a = statistics.median(Bayesian_Model._accuracy[Bayesian_Model._keys[3]]) # b = statistics.median(Bayesian_Model._accuracy[Bayesian_Model._keys[0]]) # c = statistics.median(Bayesian_Model._accuracy[Bayesian_Model._keys[4]]) print('Accuracy / prior: ' + str(prior._alphas) + ", delta: " + str(delta) + ", epsilon:" + str(epsilon)) # print mean_error plot_mean_error(datasizes, mean_error, datasizes, "Different Datasizes", [ r"$\mathsf{LSDim}$", r"$\mathsf{LSHist}$", r"$\mathsf{LSZhang}$", r"$\mathsf{EHDS}$", r"$\mathsf{EHD}$", r"$\mathsf{EHDL}$" ], "") # plot_error_box(data,"Different Datasizes",datasizes,"Accuracy VS. Data Size", # [r'$\mathcal{M}^{B}_{\mathcal{H}}$',"LapMech (sensitivity = 2)", "LapMech (sensitivity = 3)"], # ['lightblue', 'navy', 'red']) return
def mean_error_fix_n(n, prior, epsilon, times, mech): Bayesian_Model = BayesInferwithDirPrior(prior, n, epsilon) Bayesian_Model._set_observation(gen_dataset_rand(len(prior._alphas), n)) Bayesian_Model._set_candidate_scores() candidates = Bayesian_Model._candidates meanerror = [] xstick = [] for c in candidates: accuracy = [] Bayesian_Model._set_observation(c._alphas) for i in range(times): if (mech == "lap"): Bayesian_Model._laplace_mechanism_no_post(sensitivity=1.0) elif (mech == "lappost"): Bayesian_Model._laplace_mechanism_symetric(sensitivity=1.0) accuracy.append(Bayesian_Model._posterior - Bayesian_Model._laplaced_posterior) meanerror.append(numpy.mean(accuracy)) xstick.append(str(list(numpy.array(c._alphas) - 1))) return meanerror, xstick
def row_discrete_probabilities(sample_size, epsilon, delta, prior, observation): Bayesian_Model = BayesInferwithDirPrior(prior, sample_size, epsilon, delta) Bayesian_Model._set_observation(observation) print Bayesian_Model._observation_counts Bayesian_Model._set_candidate_scores() Bayesian_Model._set_local_sensitivities() Bayesian_Model._set_up_exp_mech_with_gamma_SS() Bayesian_Model._set_up_exp_mech_with_SS() Bayesian_Model._set_up_exp_mech_with_GS() Bayesian_Model._set_up_exp_mech_with_LS() ############################################################################# #SPLIT THE BINS ############################################################################# Candidate_bins_by_step = {} probability_distance_pairs_in_exp = [] nomalizer = 0.0 sorted_scores = sorted(Bayesian_Model._candidate_scores.items(), key=operator.itemgetter(1)) counter = 0 while counter < len(sorted_scores): flage = counter key = str(sorted_scores[flage][1]) Candidate_bins_by_step[key] = [] # parameters_of_bin = [] while counter < len(sorted_scores) and sorted_scores[flage][ 1] == sorted_scores[counter][1]: Candidate_bins_by_step[key].append(sorted_scores[counter][0]) # parameters_of_bin.append(sorted_scores[counter][0]._alphas) counter += 1 # print parameters_of_bin print key ############################################################################# #SPLIT THE BINS ############################################################################# # Candidate_bins_by_step = {} # for r in Bayesian_Model._candidates: # if str(sorted(r._alphas)) not in Candidate_bins_by_step.keys(): # Candidate_bins_by_step[str(sorted(r._alphas))] = [] # for c in Bayesian_Model._candidates: # if set(c._alphas) == set(r._alphas): # Candidate_bins_by_step[str(sorted(r._alphas))].append(c) ############################################################################# #SUM UP the prob within the same bin ############################################################################# # exp = calculate_prob_exp(Candidate_bins_by_step, Bayesian_Model, mechanism_parameter = 4, # sensitivity = Bayesian_Model._SS, savename = "_exp.txt") ############################################################################# #SUM UP the prob within the same bin ############################################################################# exp_gamma = calculate_prob_exp(Candidate_bins_by_step, Bayesian_Model, "gamma") ############################################################################# #SUM UP the prob within the same bin ############################################################################# exp_LS = calculate_prob_exp(Candidate_bins_by_step, Bayesian_Model, "local") ############################################################################# #SUM UP the prob within the same bin ############################################################################# exp_GS = calculate_prob_exp(Candidate_bins_by_step, Bayesian_Model, "exp") ############################################################################# #SETTING THE SENSITIVITY ############################################################################# if (len(prior._alphas) == 2): sensitivity1 = 1.0 sensitivity2 = 2.0 else: sensitivity1 = 2.0 sensitivity2 = len(prior._alphas) * 1.0 ############################################################################# #CALCULATE the Laplace prob within the same bin ############################################################################# step, lap_1 = calculate_prob_lap(Candidate_bins_by_step, Bayesian_Model, sensitivity=sensitivity1, savename="_lap_1.txt") step, lap_2 = calculate_prob_lap(Candidate_bins_by_step, Bayesian_Model, sensitivity=sensitivity2, savename="_lap_2.txt") print step, exp_gamma, lap_1, lap_2 # return ############################################################################# #PLOT the prob within the same bin ############################################################################# ############################################################################# #LABELS SETTING ############################################################################# labels = [ r'Alg 5 - $\mathsf{EHDS}$ ', r"Alg 4 - $\mathsf{EHDL}$", r"Alg 3 - $\mathsf{EHD}$", r'Alg 1 - $\mathsf{LSDim}$ (sensitivity = ' + str(sensitivity2) + ')', r'Alg 2 - $\mathsf{LSHist}$ (sensitivity = ' + str(sensitivity1) + ')' ] ############################################################################# #PLOTTING ############################################################################# plt.figure() plt.plot(step, lap_2, '-', color='lightblue', label=(labels[3])) plt.plot(step, lap_1, '-', color='navy', label=(labels[4])) plt.plot(step, exp_GS, '-', label=(labels[2])) plt.plot(step, exp_LS, '-', label=(labels[1])) plt.plot(step, exp_gamma, '-', label=(labels[0])) # plt.plot(step, exp, label=(labels[0])) # plt.plot(step, exp_new, label=(labels[1])) # plt.plot(step, exp_LS, label=(labels[2])) # plt.plot(step, exp_GS, label=(labels[3])) # plt.plot(step, lap_1, color = 'navy', label=(labels[4])) # plt.plot(step, lap_2, color = 'lightblue', label=(labels[5])) ############################################################################# #PLOT FEATURE SETTING ############################################################################# plt.xlabel("c / Hellinger distance from true posterior") plt.ylabel("Pr[H(BI(x),r) = c]") plt.title("Accuracy with Data size " + str(sample_size), fontsize=15) plt.legend() plt.grid() plt.show()