<jupyter_start><jupyter_text>Supplemental Figure 2<jupyter_code># plot public

params = {'legend.fontsize': 20}

plt.rcParams.update(params)
public = np.concatenate([500-np.argsort(public_scores['rf']), 500-np.argsort(public_scores['lr'])])
index = np.concatenate([range(500), range(500)])
method = np.concatenate([['Random Forest'] * 500, ['Logistic Regression'] * 500])

arg_scores = {'rank':public, 'index':index, 'Method':method}
arg_scores_df = pd.DataFrame.from_dict(arg_scores)

fig = plt.figure(figsize=(6,4))
g = sns.lmplot(x="index", y="rank", hue="Method", data=arg_scores_df, size=10,
               y_jitter=.02, logistic=False, legend=True)
g.set(xlim=(0, 500), ylim=(0, 500))

plt.title('Non-Private', fontsize=30)
plt.xlabel('Training Epoch', fontsize=24)
plt.ylabel('Transfer Learning Ranking', fontsize=24)
plt.tick_params(axis='both', which='major', labelsize=18)
g.savefig('./figures/Supplemental_Figure_2A.png', bbox_inches='tight')

# plot private
private = np.concatenate([500-np.argsort(epoch_scores['rf']), 500-np.argsort(epoch_scores['lr'])])
index = np.concatenate([range(500), range(500)])
method = np.concatenate([['Random Forest'] * 500, ['Logistic Regression'] * 500])

arg_scores = {'rank':private, 'index':index, 'Method':method}
arg_scores_df = pd.DataFrame.from_dict(arg_scores)

fig = plt.figure(figsize=(6,4))
g = sns.lmplot(x="index", y="rank", hue="Method", data=arg_scores_df, size=10,
               y_jitter=.02, logistic=False, legend=True)
g.set(xlim=(0, 500), ylim=(0, 500))

plt.title('Private', fontsize=30)
plt.xlabel('Training Epoch', fontsize=24)
plt.ylabel('Transfer Learning Ranking', fontsize=24)
plt.tick_params(axis='both', which='major', labelsize=18)
g.savefig('./figures/Supplemental_Figure_2B.png', bbox_inches='tight')<jupyter_output><empty_output><jupyter_text>Supplemental Figure 3<jupyter_code># plot public based on score instead of rank
params = {'legend.fontsize': 20}
plt.rcParams.update(params)
public = np.concatenate([public_scores['rf'], public_scores['lr']])
index = np.concatenate([range(500), range(500)])
method = np.concatenate([['Random Forest'] * 500, ['Logistic Regression'] * 500])

arg_scores = {'score':public, 'index':index, 'Method':method}
arg_scores_df = pd.DataFrame.from_dict(arg_scores)

plt.figure(figsize=(6,4))
g = sns.lmplot(x="index", y="score", hue="Method", data=arg_scores_df, size=10,
               y_jitter=.02, logistic=False, legend=True, legend_out=True)
g.set(xlim=(0, 500), ylim=(0, 1))

plt.title('Non-Private', fontsize=30)
plt.xlabel('Training Epoch', fontsize=24)
plt.ylabel('Transfer Learning Score', fontsize=24)
plt.tick_params(axis='both', which='major', labelsize=18)
g.savefig('./figures/Supplemental_Figure_3A.png', bbox_inches='tight')

# plot private based on score instead of rank
private = np.concatenate([epoch_scores['rf'], epoch_scores['lr']])
index = np.concatenate([range(500), range(500)])
method = np.concatenate([['Random Forest'] * 500, ['Logistic Regression'] * 500])

arg_scores = {'score':private, 'index':index, 'Method':method}
arg_scores_df = pd.DataFrame.from_dict(arg_scores)

plt.figure(figsize=(6,4))
g = sns.lmplot(x="index", y="score", hue="Method", data=arg_scores_df, size=10,
               y_jitter=.02, logistic=False, legend=True, legend_out=True)
g.set(xlim=(0, 500), ylim=(0, 1))

plt.title('Private', fontsize=30)
plt.xlabel('Training Epoch', fontsize=24)
plt.ylabel('Transfer Learning Score', fontsize=24)
plt.tick_params(axis='both', which='major', labelsize=18)
g.savefig('./figures/Supplemental_Figure_3B.png', bbox_inches='tight')<jupyter_output><empty_output><jupyter_text>Generate Samples for visualization and machine learning<jupyter_code>import os
os.environ["CUDA_DEVICE_ORDER"]="PCI_BUS_ID"   # see issue #152
os.environ["CUDA_VISIBLE_DEVICES"]="1"

from keras.models import load_model

acgan = __import__('mimic_ac_gan')

generate_count = 1000
latent_size = 100

X_private = []
y_private = []

X_public = []
y_public = []

for i in range(len(top_10)):
    print(i)
    private_gen = load_model(private_dir + '/params_generator_epoch_' + "{0:0=3d}".format(top_10[i]) + '.h5')
    public_gen = load_model(public_dir + '/params_generator_epoch_' + "{0:0=3d}".format(top_10_public[i]) + '.h5')
    
    noise = np.random.uniform(-1, 1, (generate_count, latent_size))
    sampled_labels = np.random.randint(0, 2, generate_count)
    
    X_public.extend(public_gen.predict([noise, sampled_labels.reshape((-1, 1))], verbose=0))
    y_public.extend(sampled_labels)

    X_private.extend(private_gen.predict([noise, sampled_labels.reshape((-1, 1))], verbose=0))
    y_private.extend(sampled_labels)

X_private = np.array(X_private)
y_private = np.array(y_private)

X_public = np.array(X_public)
y_public = np.array(y_public)
print(X_private.shape, y_private.shape, X_public.shape, y_public.shape)

X_public = X_public.reshape(X_public.shape[0], X_public.shape[2], X_public.shape[3]).clip(min=0).astype('int')
X_private = X_private.reshape(X_private.shape[0], X_private.shape[2], X_private.shape[3]).clip(min=0).astype('int')
print(X_private.shape)
epochs = 500 - 1

last_priv_gen = load_model(private_dir + '/params_generator_epoch_' + str(epochs) + '.h5')
last_public_gen = load_model(public_dir + '/params_generator_epoch_' + str(epochs) + '.h5')
noise = np.random.uniform(-1, 1, (generate_count, latent_size))
sampled_labels = np.random.randint(0, 2, generate_count)

last_X_private = last_priv_gen.predict([noise, sampled_labels.reshape((-1, 1))], verbose=0)
last_X_public = last_public_gen.predict([noise, sampled_labels.reshape((-1, 1))], verbose=0)

last_y_private = sampled_labels
last_y_public = sampled_labels

last_X_public = last_X_public.reshape(last_X_public.shape[0],
                                      last_X_public.shape[2],
                                      last_X_public.shape[3]).clip(min=0).astype('int')
last_X_private = last_X_private.reshape(last_X_private.shape[0],
                                        last_X_private.shape[2], 
                                        last_X_private.shape[3]).clip(min=0).astype('int')
real_split = 7500
X_train = X_real[:real_split]
X_test = X_real[real_split:]

y_train = y_real[:real_split]
y_test = y_real[real_split:]<jupyter_output><empty_output><jupyter_text>Figure 2<jupyter_code>from sklearn.ensemble import RandomForestClassifier
from sklearn import linear_model
from sklearn.svm import LinearSVC
from sklearn import neighbors

from sklearn.metrics import roc_auc_score
from sklearn.model_selection import cross_val_score

scores = {'real_rf':[], 'public_rf':[], 'private_rf':[],
          'real_linear':[], 'public_linear':[], 'private_linear':[], 
          'real_svm': [], 'public_svm': [], 'private_svm': [],
          'real_nn': [], 'public_nn': [], 'private_nn': []}
full_scores = {}

X_train = X_train.reshape(X_train.shape[0], -1)
X_test = X_test.reshape(X_test.shape[0], -1)
X_real = X_real.reshape(X_real.shape[0], -1)
X_public = X_public.reshape(X_public.shape[0], -1)
X_private = X_private.reshape(X_private.shape[0], -1)

print(X_train.shape, X_test.shape, X_real.shape, X_public.shape, X_private.shape)
print(y_train.shape, y_test.shape)

rf_clf = RandomForestClassifier(random_state=0, n_jobs=-1)
nn_clf = neighbors.KNeighborsClassifier(n_jobs=-1)
svm_clf = LinearSVC(C=1.0, random_state=0)
lr_clf = linear_model.LogisticRegression(random_state=0, n_jobs=-1)

full_real_rf_clf = RandomForestClassifier(random_state=0, n_jobs=-1)
full_real_nn_clf = neighbors.KNeighborsClassifier(n_jobs=-1)
full_real_svm_clf = LinearSVC(C=1.0, random_state=0)
full_real_lr_clf = linear_model.LogisticRegression(random_state=0, n_jobs=-1)

full_public_rf_clf = RandomForestClassifier(random_state=0, n_jobs=-1)
full_public_nn_clf = neighbors.KNeighborsClassifier(n_jobs=-1)
full_public_svm_clf = LinearSVC(C=1.0, random_state=0)
full_public_lr_clf = linear_model.LogisticRegression(random_state=0, n_jobs=-1)

full_private_rf_clf = RandomForestClassifier(random_state=0, n_jobs=-1)
full_private_nn_clf = neighbors.KNeighborsClassifier(n_jobs=-1)
full_private_svm_clf = LinearSVC(C=1.0, random_state=0)
full_private_lr_clf = linear_model.LogisticRegression(random_state=0, n_jobs=-1)
print('Real Random Forest')
real_y_pred = full_real_rf_clf.fit(X_train, y_train).predict_proba(X_test)
full_scores['real_rf'] = (roc_auc_score(y_test, real_y_pred[:, 1]))

print('Public Random Forest')
public_y_pred = full_public_rf_clf.fit(X_public, y_public).predict_proba(X_test)
full_scores['public_rf'] = (roc_auc_score(y_test, public_y_pred[:, 1]))

print('Private Random Forest')
private_y_pred = full_private_rf_clf.fit(X_private, y_private).predict_proba(X_test)
full_scores['private_rf'] = (roc_auc_score(y_test, private_y_pred[:, 1]))

# Nearest Neighbors
print('Real Nearest Neighbors')
real_y_pred = full_real_nn_clf.fit(X_train, y_train).predict_proba(X_test)
full_scores['real_nn'] = (roc_auc_score(y_test, real_y_pred[:, 1]))

print('Public Nearest Neighbors')
public_y_pred = full_private_nn_clf.fit(X_public, y_public).predict_proba(X_test)
full_scores['public_nn'] = (roc_auc_score(y_test, public_y_pred[:, 1]))

print('Private Nearest Neighbors')
private_y_pred = full_private_nn_clf.fit(X_private, y_private).predict_proba(X_test)
full_scores['private_nn'] = (roc_auc_score(y_test, private_y_pred[:, 1]))

# SVM
print('Real SVM')
real_y_pred = full_real_svm_clf.fit(X_train, y_train).decision_function(X_test)
full_scores['real_svm'] = (roc_auc_score(y_test, real_y_pred))

print('Public SVM')
public_y_pred = full_public_svm_clf.fit(X_public, y_public).decision_function(X_test)
full_scores['public_svm'] = (roc_auc_score(y_test, public_y_pred))

print('Private SVM')
private_y_pred = full_private_svm_clf.fit(X_private, y_private).decision_function(X_test)
full_scores['private_svm'] = (roc_auc_score(y_test, private_y_pred))

# Logistic Regression
print('Real Logistic Regression')
real_y_pred = full_real_lr_clf.fit(X_train, y_train).predict_proba(X_test)
full_scores['real_linear'] = (roc_auc_score(y_test, real_y_pred[:, 1]))

print('Public Logistic Regression')
public_y_pred = full_public_lr_clf.fit(X_public, y_public).predict_proba(X_test)
full_scores['public_linear'] = (roc_auc_score(y_test, public_y_pred[:, 1]))

print('Private Logistic Regression')
private_y_pred = full_private_lr_clf.fit(X_private, y_private).predict_proba(X_test)
full_scores['private_linear'] = (roc_auc_score(y_test, private_y_pred[:, 1]))

print(full_scores)
pkl.dump(full_scores, open('/data/SPRINT/MIMIC/mimic_full_scores.p', 'wb'))
# shuffle generated examples
indices = range(X_private.shape[0])
np.random.shuffle(indices)

for i in range(10):
    print(i)
    start = i * generate_count
    stop = (i+1) * generate_count
    
    # real don't rely on indices because only 1 training set / 1 holdout
    # variability is from random state
    real_y_pred = rf_clf.fit(X_train, y_train).predict_proba(X_test)
    scores['real_rf'].append(roc_auc_score(y_test, real_y_pred[:, 1]))

    public_y_pred = rf_clf.fit(X_public[indices[start:stop]],
                               y_public[indices[start:stop]]).predict_proba(X_test)
    scores['public_rf'].append(roc_auc_score(y_test, public_y_pred[:, 1]))
    
    private_y_pred = rf_clf.fit(X_private[indices[start:stop]],
                                y_private[indices[start:stop]]).predict_proba(X_test)
    scores['private_rf'].append(roc_auc_score(y_test, private_y_pred[:, 1]))

    # Nearest Neighbors
    real_y_pred = nn_clf.fit(X_train, y_train).predict_proba(X_test)
    scores['real_nn'].append(roc_auc_score(y_test, real_y_pred[:, 1]))
    
    public_y_pred = nn_clf.fit(X_public[indices[start:stop]],
                               y_public[indices[start:stop]]).predict_proba(X_test)
    scores['public_nn'].append(roc_auc_score(y_test, public_y_pred[:, 1]))

    private_y_pred = nn_clf.fit(X_private[indices[start:stop]],
                                y_private[indices[start:stop]]).predict_proba(X_test)
    scores['private_nn'].append(roc_auc_score(y_test, private_y_pred[:, 1]))

    # SVM
    real_y_pred = svm_clf.fit(X_train, y_train).decision_function(X_test)
    scores['real_svm'].append(roc_auc_score(y_test, real_y_pred))
    
    public_y_pred = svm_clf.fit(X_public[indices[start:stop]],
                                y_public[indices[start:stop]]).decision_function(X_test)
    scores['public_svm'].append(roc_auc_score(y_test, public_y_pred))

    private_y_pred = svm_clf.fit(X_private[indices[start:stop]],
                                 y_private[indices[start:stop]]).decision_function(X_test)
    scores['private_svm'].append(roc_auc_score(y_test, private_y_pred))

    # Logistic Regression
    real_y_pred = lr_clf.fit(X_train, y_train).predict_proba(X_test)
    scores['real_linear'].append(roc_auc_score(y_test, real_y_pred[:, 1]))
    
    public_y_pred = lr_clf.fit(X_public[indices[start:stop]],
                               y_public[indices[start:stop]]).predict_proba(X_test)
    scores['public_linear'].append(roc_auc_score(y_test, public_y_pred[:, 1]))

    private_y_pred = lr_clf.fit(X_private[indices[start:stop]],
                                y_private[indices[start:stop]]).predict_proba(X_test)
    scores['private_linear'].append(roc_auc_score(y_test, private_y_pred[:, 1]))
        
print(scores)
import matplotlib.pylab as pylab
params = {'legend.fontsize': 'x-large',
          'axes.labelsize': 40,
          'axes.titlesize':'x-large',
          'xtick.labelsize':15,
          'ytick.labelsize':15,
          'legend.edgecolor': 'black'}
pylab.rcParams.update(params)

transfer_scores = pd.DataFrame.from_dict(scores, orient='index')
print(transfer_scores)

full_scores_df = pd.DataFrame.from_dict(data=full_scores, orient='index')
full_scores_df.columns = ['Score']<jupyter_output>0         1         2         3         4         5  \
real_rf         0.580548  0.580548  0.580548  0.580548  0.580548  0.580548   
private_nn      0.573122  0.566047  0.560991  0.571939  0.562800  0.563562   
public_linear   0.560566  0.567002  0.558988  0.555904  0.558231  0.560417   
public_rf       0.522660  0.534511  0.536644  0.555085  0.549398  0.520872   
public_nn       0.551216  0.509823  0.518787  0.518046  0.506826  0.505958   
private_linear  0.580001  0.600277  0.575164  0.583874  0.587703  0.584075   
private_rf      0.603374  0.597473  0.616001  0.583041  0.601355  0.595331   
real_svm        0.596842  0.596842  0.596842  0.596842  0.596842  0.596842   
private_svm     0.577617  0.597710  0.582375  0.587282  0.584873  0.581078   
real_nn         0.570077  0.570077  0.570077  0.570077  0.570077  0.570077   
public_svm      0.526857  0.538344  0.537442  0.529862  0.529591  0.502892   
real_linear     0.592768  0.592768  0.592768  0.592768  0.592768[...]<jupyter_text>Figure 3<jupyter_code>from matplotlib import gridspec

sns.set_style('darkgrid')

visit_codes = ['1', '2', '3', '4', '5',
               '1', '2', '3', '4', '5',
               '1', '2', '3', '4', '5',
               '1', '2', '3', '4', '5',
               '1', '2', '3', '4', '5',
               '1', '2', '3', '4', '5',
               '1', '2', '3', '4', '5',
               '1', '2', '3', '4', '5',
               '1', '2', '3', '4', '5']

d = pd.DataFrame(X_train)
corr = d.corr()
mask = np.zeros_like(corr, dtype=np.bool)
mask[np.triu_indices_from(mask)] = True
cmap = sns.diverging_palette(220, 10, as_cmap=True)

fig = plt.figure(figsize=(9, 8))
ax0 = sns.heatmap(corr, mask=mask, cmap=cmap, vmax=1,
            square=True, xticklabels=visit_codes, yticklabels=visit_codes,
            linewidths=.5, cbar=1, cbar_kws={"fraction": 0.05,
                                             "shrink": 0.5,
                                             "orientation": "vertical"})
ax0.set_title("Real Correlation Structure")
plt.show()
fig.savefig('./figures/Figure_3A.png', bbox_inches='tight')

fig = plt.figure(figsize=(9, 8))
d = pd.DataFrame(X_private)
private_corr = d.corr()
mask = np.zeros_like(private_corr, dtype=np.bool)
mask[np.triu_indices_from(mask)] = True
cmap = sns.diverging_palette(220, 10, as_cmap=True)
ax2 = sns.heatmap(private_corr, mask=mask, cmap=cmap, vmax=1,
            square=True, xticklabels=visit_codes, yticklabels=visit_codes,
            linewidths=.5, cbar=1, cbar_kws={"fraction": 0.05,
                                             "shrink": 0.5,
                                             "orientation": "vertical"})
ax2.set_title("Private Correlation Structure")
sns.set_style('whitegrid')
plt.show()
fig.savefig('./figures/Figure_3C.png', bbox_inches='tight')
real_matrix = corr.as_matrix()
real_list = []

private_matrix = private_corr.as_matrix()
private_list = []

# only examine below the triangle
for i in range(36):
    for j in range(36):
        if j < i:
            real_list.append(real_matrix[i, j])
            private_list.append(private_matrix[i, j])
from scipy.stats import spearmanr
print('Real to private')
print(spearmanr(real_list, private_list))<jupyter_output>Real to private
SpearmanrResult(correlation=0.55982933885422947, pvalue=2.9954485491603306e-53)<jupyter_text>Figure 4<jupyter_code>import matplotlib.lines as mlines

markers = ['o', '^', 's']
colors = ['#B21E0D', '#FF412B', '#0E5FCC', '#537CB2', '#9300B2', '#DA2BFF']


full_scores_df = pd.DataFrame.from_dict(data=full_scores, orient='index')
full_scores_df.columns = ['Score']
full_scores_df['models'] = ['combined'] * 12
# full_scores_df.loc[full_scores_df['real_rf'], 'method'] = 'Real'
full_scores_df.loc[['real_rf', 'real_nn', 'real_svm', 'real_linear'], 'method'] = 'Real'
full_scores_df.loc[['public_rf', 'real_nn', 'real_svm', 'real_linear'], 'privacy'] = 'Real'

score_df_rf = transfer_scores[0]
#score_df_rf['real_rf']['method'] = 'Real'
score_df_rf = pd.DataFrame(score_df_rf)
score_df_rf.columns = ['Score']
score_df_rf['models'] = ['top_rf'] * 12
score_df_rf.drop(['real_rf', 'real_nn', 'real_svm', 'real_linear'], inplace=True)

score_df_lr = transfer_scores[5]
score_df_lr = pd.DataFrame(score_df_lr)
score_df_lr.columns = ['Score']
score_df_lr['models'] = ['top_lr'] * 12
score_df_lr.drop(['real_rf', 'real_nn', 'real_svm', 'real_linear'], inplace=True)
full_scores_df = full_scores_df.append(score_df_rf).append(score_df_lr)

full_scores_df['privacy'] = [d.split('_')[0] for d in full_scores_df.index]
full_scores_df = pd.concat([full_scores_df, pd.get_dummies(full_scores_df['privacy'])], axis=1)
full_scores_df['meth_group'] = [d.split('_')[1] for d in full_scores_df.index] #.split('_')
full_scores_df = pd.concat([full_scores_df, pd.get_dummies(full_scores_df['meth_group'])], axis=1)

real_rf_score = full_scores_df.loc['real_rf']['Score']
real_lr_score = full_scores_df.loc['real_linear']['Score']
real_svm_score = full_scores_df.loc['real_svm']['Score']
real_nn_score = full_scores_df.loc['real_nn']['Score']
print(real_rf_score)


fig = plt.figure(figsize=(3, 3))
df = full_scores_df
private_lr = df.loc[(df['meth_group'] == 'linear') & (df['private'] == 1.0)]

n = sns.stripplot(data=private_lr, y="Score", x="models",
                  hue="privacy", size=16, marker=markers[2], split=True,
                  palette=[colors[4]])

real_patch = mlines.Line2D([], [], color=colors[0],
              label='Real (Benchmark)')
private_patch = mlines.Line2D([], [], marker=markers[2], 
                              markersize=14, linewidth=0, color=colors[4])

methods = ["Top 10", "RF", "LR"]
n.set_xticklabels(methods)
plt.tick_params(axis='both', which='major', labelsize=12)
plt.title('Logistic Regression Transfer Learning', fontsize=14)
plt.ylim([0.5, 0.75])
n.legend_.remove()
plt.xlabel('Model Epoch Selection Method', fontsize=14)
plt.ylabel('AUROC', fontsize=14)

# plt.legend(handles=[real_patch, public_patch, private_patch],
#            labels=['Real (Benchmark)', 'Non-Private', 'Private'],
#            loc='right', ncol=1,
#            bbox_to_anchor=(1.4, 0.5), fancybox=True)
plt.plot(np.linspace(-20,120,1000), [real_lr_score]*1000, colors[0])
fig.savefig('./figures/Figure_4A.png', bbox_inches='tight')


fig = plt.figure(figsize=(3, 3))
private_rf = df.loc[(df['meth_group'] == 'rf') & (df['private'] == 1.0)]

n = sns.stripplot(data=private_rf, y="Score", x="models",
                  hue="privacy", size=16, marker=markers[2], split=True,
                  palette=[colors[4]])
n.set_xticklabels(methods)
plt.tick_params(axis='both', which='major', labelsize=12)
plt.title('Random Forest', fontsize=14)
plt.ylim([0.5, 0.75])
plt.xlabel('Model Epoch Selection Method', fontsize=14)
plt.ylabel('AUROC', fontsize=14)
n.legend_.remove()
plt.plot(np.linspace(-20,120,1000), [real_rf_score]*1000, colors[0])
fig.savefig('./figures/Figure_4B.png', bbox_inches='tight')

fig = plt.figure(figsize=(3,3))
private_svm = df.loc[(df['meth_group'] == 'svm') & (df['private'] == 1.0)]

n = sns.stripplot(data=private_svm, y="Score", x="models",
                  hue="privacy", size=16, marker=markers[2], split=True,
                  palette=[colors[4]])


n.set_xticklabels(methods)
plt.tick_params(axis='both', which='major', labelsize=12)
plt.title('Support Vector Machine', fontsize=14)
plt.ylim([0.5, 0.75])
plt.xlabel('Model Epoch Selection Method', fontsize=14)
plt.ylabel('AUROC', fontsize=14)
n.legend_.remove()
plt.plot(np.linspace(-20,120,1000), [real_svm_score]*1000, colors[0])
fig.savefig('./figures/Figure_4C.png', bbox_inches='tight')

fig = plt.figure(figsize=(3, 3))
private_nn = df.loc[(df['meth_group'] == 'nn') & (df['private'] == 1.0)]

n = sns.stripplot(data=private_nn, y="Score", x="models",
                  hue="privacy", size=16, marker=markers[2], split=True,
                  palette=[colors[4]])

n.set_xticklabels(methods)
plt.tick_params(axis='both', which='major', labelsize=12)
plt.title('Nearest Neighbors', fontsize=14)
plt.ylim([0.5, 0.75])
plt.xlabel('Model Epoch Selection Method', fontsize=14)
plt.ylabel('AUROC', fontsize=14)
n.legend_.remove()
plt.plot(np.linspace(-20,120,1000), [real_nn_score]*1000, colors[0])
fig.savefig('./figures/Figure_4D.png', bbox_inches='tight')
real_rf_importances = full_real_rf_clf.feature_importances_
private_rf_importances = full_private_rf_clf.feature_importances_

real_lr_coefs = full_real_lr_clf.coef_[0]
private_lr_coefs = full_private_lr_clf.coef_[0]

real_svm_coefs = full_real_svm_clf.coef_[0]
private_svm_coefs = full_private_svm_clf.coef_[0]
from scipy.stats import spearmanr
from scipy.stats import pearsonr

print('RF')
print(spearmanr(real_rf_importances, private_rf_importances))

print('SVM')
print(spearmanr(real_svm_coefs, private_svm_coefs))

print('LR')
print(spearmanr(real_lr_coefs, private_lr_coefs))<jupyter_output>RF
SpearmanrResult(correlation=0.4059288537549407, pvalue=0.0056635770876225268)
SVM
SpearmanrResult(correlation=0.29525691699604739, pvalue=0.048947206483028687)
LR
SpearmanrResult(correlation=0.4268774703557312, pvalue=0.0034516453249828212)
{'fraction_non_alphanumeric': 0.15777545327754533, 'fraction_numerical': 0.053565202231520226, 'mean_word_length': 5.0701058201058204, 'pattern_counts': {'":': 6, '<': 23, '<?xml version=': 0, '>': 22, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 15, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '384255', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 9611, 'n_tokens_neox': 8758, 'n_words': 1299, 'path': 'MIMIC/MIMICAnalysis.ipynb', 'repo_name': 'aaroncwhite/SPRINT_gan', 'size': '22944'}