<jupyter_start><jupyter_text>Plot Marginal KDE (for Adult)<jupyter_code>import numpy as np
import scipy as sp
import pickle
import matplotlib.pyplot as plt
import seaborn as sns
import pandas as pd
import copy
import importlib
import matplotlib
matplotlib.rcParams['ps.useafm'] = True
matplotlib.rcParams['pdf.use14corefonts'] = True
matplotlib.rcParams['text.usetex'] = True
sns.set_style("white")
#load data
with open('./data/ad_train_drop', 'rb') as handle:
    ad_train = pickle.load(handle)

#Move into vectors
y = ad_train['y']
x = ad_train['x'].values
D = ad_train['D']
N = ad_train['N']

with open('./data/ad_test_drop', 'rb') as handle:
    ad_test = pickle.load(handle)

#Move into vectors
y_test = ad_test['y']
x_test = ad_test['x'].values
N_test = ad_test['N']
#load parameters
par_nuts = pd.read_pickle('./parameters/par_nuts_logreg_ad_ARD_seed101')
par_advi = pd.read_pickle('./parameters/par_advi_logreg_ad_ARD_seed101')

a =1
b =1
par_bb = pd.read_pickle('./parameters/par_bb_logreg_c0_a{}_b{}_gN_ad_B2000_seed101'.format(a,b))


beta_nuts = par_nuts.iloc[:,9:D+9][0:2000]
alpha_nuts = par_nuts.iloc[:,D+9][0:2000]

beta_advi = par_advi.iloc[:,0:D]
alpha_advi = par_advi.iloc[:,D]

beta_bb = par_bb['beta'][:,0:D]
alpha_bb = par_bb['beta'][:,D]
ind = 13
#ind = 5

f=plt.figure(figsize = (15,4))
plt.subplot(1,3,2)
plt.title('NUTS',fontsize = 18)
sns.distplot(beta_nuts['beta[{}]'.format(ind)])
plt.xlabel(r'$\beta_{{{}}}$'.format(ind),fontsize = 14)
plt.xlim(-1.5,0.5)
plt.ylim(0,6)
plt.ylabel('Posterior density',fontsize = 14)

plt.subplot(1,3,1)
sns.distplot(beta_bb[:,ind-1])
plt.title('Loss-NPL',fontsize = 18)
plt.xlabel(r'$\beta_{{{}}}$'.format(ind),fontsize = 14)
plt.xlim(-1.5,0.5)
plt.ylim(0,6)
plt.ylabel('Posterior density',fontsize = 14)

plt.subplot(1,3,3)
sns.distplot(beta_advi['beta[{}]'.format(ind)])
plt.title('ADVI',fontsize = 18)
plt.xlabel(r'$\beta_{{{}}}$'.format(ind),fontsize = 14)
plt.xlim(-1.5,0.5)
plt.ylim(0,6)
plt.ylabel('Posterior density',fontsize = 14)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1944854751354013, 'fraction_numerical': 0.041851304775972424, 'mean_word_length': 6.639097744360902, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '509348', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 954, 'n_tokens_neox': 885, 'n_words': 138, 'path': 'experiments/LogReg_ARD/Plot marginal KDE (for Adult).ipynb', 'repo_name': 'edfong/npl', 'size': '2031'}