<jupyter_start><jupyter_text>2.2 Relative model fit (individual level model comparison)  Load WAICs<jupyter_code>waic_summaries = [file for file in os.listdir(os.path.join('results', 'model_comparison', 'additive_vs_multiplicative'))
                  if file.endswith('waic.csv')]

n_krajbich2010 = 39
n_krajbich2011 = 30
n_folke2016 = 24
n_tavares2017 = 25
n = n_krajbich2010 + n_krajbich2011 + n_folke2016 + n_tavares2017

waic = pd.DataFrame(dict(subject=np.arange(n)))
waic['dWAIC'] = np.nan
waic['dSE'] = np.nan
waic['dataset'] = np.nan
waic['warning'] = np.nan

for file in waic_summaries:
    _, _, _, subject, _ = file.split('_')
    subject = int(subject)

    waic_summary = pd.read_csv(os.path.join('results', 'model_comparison',
                                            'additive_vs_multiplicative', file), index_col='Unnamed: 0')
    waic.loc[waic['subject'] == subject, 'dWAIC'] = waic_summary.loc['GLAM', 'WAIC'] - waic_summary.loc['additive', 'WAIC']
    waic.loc[waic['subject'] == subject, 'dSE'] = waic_summary['dSE'].values[1]
    waic.loc[waic['subject'] == subject, 'warning'] = waic_summary['var_warn'].sum()

waic.sort_values('subject', inplace=True)
waic['dataset'] = np.array(n_krajbich2010 * ['krajbich2010'] + n_krajbich2011 * ['krajbich2011'] + n_folke2016 * ['folke2016'] + n_tavares2017 * ['tavares2017'])

waic.head()<jupyter_output><empty_output><jupyter_text>Plot WAIC differences between multiplicative and additive GLAM variants  Panel a<jupyter_code>def figure_si_2a(waic, colors=None, fontsize=7, figsize=cm2inch((18, 6)), plot_type='bar', log_scale=False, ylim=(-50, 100), plot_legend=True, ax=None):

    # Log transform: add minimum dWAIC + 1, then log-transform, new indifference then at log(minimum dWAIC + 1)
    waic = waic.copy()
    if log_scale:
        min_dWAIC = np.min(waic['dWAIC'])
        indifference_level = np.log(np.abs(min_dWAIC) + 1)
        waic['plotted_dWAIC'] = np.log(waic['dWAIC'] + np.abs(min_dWAIC) + 1)
    else:
        indifference_level = 0
        waic['plotted_dWAIC'] = waic['dWAIC']
    
    if colors is None:
        colors = np.array(['C{}'.format(i) for i in range(10)])

    datasets = ['krajbich2010', 'krajbich2011', 'folke2016', 'tavares2017']
    dataset_labels = ['Krajbich 2010', 'Krajbich 2011', 'Folke 2016', 'Tavares 2017']
    
    if ax is None:
        fig, ax = plt.subplots(figsize=figsize)

    sorting_idx = np.argsort(waic['plotted_dWAIC'])
    color_idx = pd.Categorical(waic['dataset'], categories=datasets).codes
    patches = []
    
    patches = [mpatches.Rectangle((0, 0), 0.5, 1, fc="C{}".format(i))
               for i in range(len(datasets))]

    for i, dataset in enumerate(datasets):

        if plot_type == 'bar':
            ax.bar(np.arange(len(waic))[waic['dataset'][sorting_idx] == dataset],
                   waic['plotted_dWAIC'][sorting_idx][waic['dataset'][sorting_idx] == dataset],
                   color=colors[i])

        else:
            ax.scatter(np.arange(len(waic))[waic['dataset'][sorting_idx] == dataset],
                       waic['plotted_dWAIC'][sorting_idx][waic['dataset'][sorting_idx] == dataset],
                       color=colors[i], marker='+')

    
    # Legend
    if plot_legend:
        ax.legend(patches,
                  ['Krajbich 2010', 'Krajbich 2011', 'Folke 2016', 'Tavares 2017'],
                  ncol=2,
                  loc='lower right',
                  handlelength=1, handleheight=1,
                  fontsize=fontsize, columnspacing=1,
                  frameon=False)
    
    
    ax.set_xlabel('Participant', fontsize=fontsize)
    if log_scale:
        ax.set_ylabel('Log(dWAIC))', fontsize=fontsize)
    else:
        ax.set_ylabel('WAIC(multiplicative)-\nWAIC(additive)', fontsize=fontsize)
    ax.set_xticks([])
    ax.tick_params(axis='both', which='major', labelsize=fontsize)
    
    ax.axhline(indifference_level, color='black', lw=1, zorder=9)
    
    ax.set_ylim(ylim)
    
    
    ax.text(-0.075, 1., 'a', transform=ax.transAxes,
                fontsize=7, fontweight='bold', va='top')
    ax.spines['top'].set_visible(False)
    ax.spines['right'].set_visible(False)
        
    # Font sizes
    ax.tick_params(axis='both', labelsize=8)
    
    return ax
figure_si_2a(waic, ylim=(-5, 5));
waic['dWAIC'].describe()
(waic['dWAIC'] > 0).sum()
(waic['dWAIC'] > 0).sum() / len(waic)<jupyter_output><empty_output><jupyter_text>Paneld bcd<jupyter_code>all_data = pd.read_csv('data/data_aggregate.csv')
even = all_data[(all_data['trial'] % 2) == 0].reset_index(drop=True)
odd = all_data[(all_data['trial'] % 2) == 1].reset_index(drop=True)
# read model predictions for multiplicative and additive variants and concatenate
prediction_additive_list = []
prediction_multiplicative_list = []

# join prediction dataframes
for subject in odd['subject'].unique():
    subject_pred_additive = pd.read_csv(os.path.join('results', 'predictions', 'out_of_sample', 'additive', 'prediction_{}_additive_oos.csv'.format(subject)), index_col=0)
    subject_pred_additive['subject'] = subject    
    prediction_additive_list.append(subject_pred_additive)

    subject_pred_multiplicative = pd.read_csv(os.path.join('results', 'predictions', 'out_of_sample', 'multiplicative', 'prediction_{}_multiplicative_oos.csv'.format(subject)), index_col=0)
    subject_pred_multiplicative['subject'] = subject
    prediction_multiplicative_list.append(subject_pred_multiplicative)

prediction_additive = pd.concat(prediction_additive_list)
prediction_multiplicative = pd.concat(prediction_multiplicative_list)
# discard trials with negative predicted RT
prediction_additive = prediction_additive[prediction_additive['rt'] > 0].copy()
prediction_multiplicative = prediction_multiplicative[prediction_multiplicative['rt'] > 0].copy()
# compute / load individual behavioural measures for odd data and model predictions
odd_summary = pd.DataFrame()
data_summary = pd.DataFrame()
pred_additive_summary = pd.DataFrame()

for di, dataset in enumerate(odd['dataset'].unique()):
    odd_di = odd[odd['dataset'] == dataset].copy()
    n_items = odd_di['n_items'].unique()[0]
    
    odd_summary_di = aggregate_subject_level(odd_di, n_items=n_items)
    
    prediction_additive_di = prediction_additive[prediction_additive['dataset'] == dataset].copy()
    
    pred_additive_summary_di = aggregate_subject_level(prediction_additive_di, n_items=n_items)
    
    
    odd_summary = pd.concat([odd_summary, odd_summary_di])
    pred_additive_summary = pd.concat([pred_additive_summary, pred_additive_summary_di])

pred_additive_summary.to_csv(os.path.join('results', 'predictions', 'out_of_sample', 'descriptives',
                                          'subject_summary_additive_oos.csv'))

pred_multiplicative_summary = pd.read_csv(os.path.join('results',
                                                       'predictions',
                                                       'out_of_sample',
                                                       'descriptives',
                                                       'subject_summary_multiplicative_oos.csv'),
                                         header=[0, 1], index_col=0)
pred_additive_summary = pd.read_csv(os.path.join('results',
                                                 'predictions',
                                                 'out_of_sample',
                                                 'descriptives',
                                                 'subject_summary_additive_oos.csv'),
                                    header=[0, 1], index_col=0)
def figure_si_2bcd(multiplicative, additive,
                 figsize=cm2inch(18, 6), colors=None, fontsize=7, alpha=0.5, axs=None, plot_legend=False):

    datasets = ['krajbich2010', 'krajbich2011', 'folke2016', 'tavares2017']

    if colors is None:
        colors = np.array(['C{}'.format(i)
                           for i in range(multiplicative['dataset']['Unnamed: 11_level_1'].unique().size)])
    color_idx = pd.Categorical(multiplicative['dataset']['Unnamed: 11_level_1'], categories=datasets, ordered=True).codes.astype(int)
    
    if axs is None:
        fig, axs = plt.subplots(1, 3, figsize=figsize, sharex='col', sharey='col')

    # b) Mean RT
    axs[0].scatter(multiplicative['rt']['mean'],
                   additive['rt']['mean'],
                   color=colors[color_idx],
                   linewidth=0,
                   marker='o',
                   alpha=alpha)
    axs[0].scatter(multiplicative['rt']['mean'],
                   additive['rt']['mean'],
                   color=colors[color_idx],
                   facecolor='none',
                   linewidth=0.5,
                   marker='o',
                   alpha=1.0)
    axs[0].set_xticks(np.arange(0, 10000, 2000))
    axs[0].set_yticks(np.arange(0, 10000, 2000))
    axs[0].set_xlim(0, 9000)
    axs[0].set_ylim(0, 9000)


    # c) P(choose best)
    axs[1].scatter(multiplicative['best_chosen']['mean'],
                   additive['best_chosen']['mean'],
                   color=colors[color_idx],
                   linewidth=0,
                   marker='o',
                   alpha=alpha)
    axs[1].scatter(multiplicative['best_chosen']['mean'],
                   additive['best_chosen']['mean'],
                   color=colors[color_idx],
                   facecolor='none',
                   linewidth=0.5,
                   marker='o',
                   alpha=1.0)

    axs[1].set_xticks(np.arange(0.4, 1.1, 0.2))
    axs[1].set_yticks(np.arange(0.4, 1.1, 0.2))
    axs[1].set_xlim(0.2, 1.0)
    axs[1].set_ylim(0.2, 1.0)



    # d) Gaze Influence
    axs[2].scatter(multiplicative['gaze_influence']['Unnamed: 10_level_1'],
                   additive['gaze_influence']['Unnamed: 10_level_1'],
                   color=colors[color_idx],
                   marker='o',
                   linewidth=0,
                   alpha=alpha)
    axs[2].scatter(multiplicative['gaze_influence']['Unnamed: 10_level_1'],
                   additive['gaze_influence']['Unnamed: 10_level_1'],
                   color=colors[color_idx],
                   marker='o',
                   facecolor='none',
                   linewidth=0.5,
                   alpha=1.0)
    
    axs[2].set_xticks(np.arange(-0.2, 1.1, 0.2))
    axs[2].set_yticks(np.arange(-0.2, 1.1, 0.2))
    axs[2].set_xlim(-0.3, 0.85)
    axs[2].set_ylim(-0.3, 0.85)

    axs[0].set_ylabel('Additive variant predicted\nMean RT (ms)', fontsize=fontsize)
    axs[0].set_xlabel('Multiplicative variant predicted\nMean RT (ms)', fontsize=fontsize)

    axs[1].set_ylabel('Additive variant predicted\nP(choose best)', fontsize=fontsize)
    axs[1].set_xlabel('Multiplicative variant predicted\nP(choose best)', fontsize=fontsize)

    axs[2].set_ylabel('Additive variant predicted\nGaze influence', fontsize=fontsize)
    axs[2].set_xlabel('Multiplicative variant predicted\nGaze influence', fontsize=fontsize)
    
    patches = [mpatches.Rectangle((0, 0), 0.5, 1, fc="C{}".format(i))
               for i in range(len(datasets))]
    if plot_legend:
        axs[0].legend(patches,
                         ['Krajbich 2010', 'Krajbich 2011', 'Folke 2016', 'Tavares 2017'],
                         loc='upper left',
                         handlelength=1, handleheight=1,
                         fontsize=fontsize,
                         frameon=False)

    # Labels
    for label, ax in zip(list('bcd'), axs.ravel()):
        ax.text(-0.33, 1.1, label, transform=ax.transAxes,
                fontsize=fontsize, fontweight='bold', va='top')
        ax.spines['top'].set_visible(False)
        ax.spines['right'].set_visible(False)
        
        # Font sizes
        ax.tick_params(axis='both', labelsize=fontsize)

        # Plot diagonal
        ax.plot(ax.get_xlim(), ax.get_xlim(), color='black', linewidth=1, alpha=1.0, zorder=-1)
            
    return axs<jupyter_output><empty_output><jupyter_text>Panels efg (additive model parameters vs. behavioural measures) – in sample<jupyter_code>odd_summary.head()
estimates = pd.DataFrame()
parameter_names = ['v', 'gamma', 's', 'tau']
for subject in odd_summary.index:
    subject_estimates_df = pd.read_csv(os.path.join('results', 'estimates', 'out_of_sample', 'additive',
                                                    'estimates_{}_additive_oos.csv'.format(subject)),
                                       index_col=0)
    subject_estimates_dict = {parameter: subject_estimates_df.loc[parameter + '__0_0', 'MAP']
                              for parameter in parameter_names}
    subject_estimates_dict['subject'] = subject
    estimates = pd.concat([estimates,
                           pd.DataFrame(subject_estimates_dict,
                                        index=np.ones(1)*subject)])

estimates.head()
def figure_si_2efg(estimates, summary,
                   figsize=cm2inch(18, 6), colors=None, fontsize=7, alpha=0.5, axs=None, plot_legend=False):

    datasets = ['krajbich2010', 'krajbich2011', 'folke2016', 'tavares2017']

    if colors is None:
        colors = np.array(['C{}'.format(i)
                           for i in range(summary['dataset'].unique().size)])
    color_idx = pd.Categorical(summary['dataset'], categories=datasets, ordered=True).codes.astype(int)
    
    if axs is None:
        fig, axs = plt.subplots(1, 3, figsize=figsize, sharex='col', sharey='col')

    # e) log Mean RT ~ log v
    axs[0].scatter(np.log(estimates['v']),
                   np.log(summary['rt']['mean']),
                   color=colors[color_idx],
                   marker='o',
                   linewidth=0,
                   alpha=alpha)
    axs[0].scatter(np.log(estimates['v']),
                   np.log(summary['rt']['mean']),
                   color=colors[color_idx],
                   marker='o',
                   facecolor='none',
                   linewidth=0.5,
                   alpha=1.0)
    axs[0].set_ylim(6, 9.125)
    
    # b) P(choose best) ~ gamma
    axs[1].scatter(estimates['gamma'],
                   summary['best_chosen']['mean'],
                   color=colors[color_idx],
                   marker='o',
                   linewidth=0,
                   alpha=alpha)
    axs[1].scatter(estimates['gamma'],
                   summary['best_chosen']['mean'],
                   color=colors[color_idx],
                   marker='o',
                   facecolor='none',
                   linewidth=0.5,
                   alpha=1.0)
    axs[1].set_ylim(0.3, 1.0)

    # c) Gaze Influence ~ gamma
    axs[2].scatter(estimates['gamma'],
                   summary['gaze_influence'],
                   color=colors[color_idx],
                   marker='o',
                   linewidth=0,
                   alpha=alpha)
    axs[2].scatter(estimates['gamma'],
                   summary['gaze_influence'],
                   color=colors[color_idx],
                   marker='o',
                   linewidth=0.5,
                   facecolor='none',
                   alpha=1.0)

    axs[0].set_ylabel('Log mean RT (ms)', fontsize=fontsize)
    axs[1].set_ylabel('P(choose best)', fontsize=fontsize)
    axs[2].set_ylabel('Gaze influence\non P(choice | value)', fontsize=fontsize)
     
    axs[0].set_xlabel(r'Log $\hat{v}$', fontsize=fontsize)
    axs[1].set_xlabel(r'$\hat{\gamma}_{additive}$', fontsize=fontsize)
    axs[2].set_xlabel(r'$\hat{\gamma}_{additive}$', fontsize=fontsize)
    
    patches = [mpatches.Rectangle((0, 0), 0.5, 1, fc="C{}".format(i))
               for i in range(len(datasets))]
    if plot_legend:
        axs[0].legend(patches,
                         ['Krajbich 2010', 'Krajbich 2011', 'Folke 2016', 'Tavares 2017'],
                         loc='upper left',
                         handlelength=1, handleheight=1,
                         fontsize=fontsize,
                         frameon=False)

    # Labels
    for label, ax in zip(list('efg'), axs.ravel()):
        ax.text(-0.3, 1.1, label, transform=ax.transAxes,
                fontsize=fontsize, fontweight='bold', va='top')
        ax.spines['top'].set_visible(False)
        ax.spines['right'].set_visible(False)
        
        # Font sizes
        ax.tick_params(axis='both', labelsize=fontsize)
            
    return axs<jupyter_output><empty_output><jupyter_text>Mixed effects regressions with random slope and intercept for data sets<jupyter_code>from bambi import Model
from pymc3 import plot_posterior
# Format data for mixed model
df = pd.concat([estimates, odd_summary], axis=1)
df['log_rt'] = np.log(df[('rt', 'mean')])
df['log_v'] = np.log(df['v'])
df['best_chosen'] = 100 * df[('best_chosen', 'mean')]
df['gaze_influence'] = 100 * df[('gaze_influence', '')]
df['dataset'] = df[('dataset', '')]

df = df[['subject', 'dataset', 'log_rt', 'best_chosen', 'gaze_influence', 'log_v', 'gamma', 's', 'tau']].copy().reset_index(drop=True)
df.head()
n_samples = 20000
result_file = os.path.join('results', 'mixed_effects_models', 'si2_parameter_behavior_e_v_rt.csv')

if not os.path.isfile(result_file):

    model_e = Model(df)
    result_e = model_e.fit('log_rt ~ log_v',
                           random=['log_v|dataset'],
                           categorical=['dataset'],
                           samples=n_samples,
                           chains=2)

    summary_e = result_e.summary(ranefs=True)
    summary_e.to_csv(result_file)
else:
    print('Loading previous results from "{}"...'.format(result_file))
    summary_e = pd.read_csv(result_file, index_col=0)
summary_e
result_file = os.path.join('results', 'mixed_effects_models', 'si2_parameter_behavior_f_gamma_best_chosen.csv')

if not os.path.isfile(result_file):
    model_f = Model(df)
    result_f = model_f.fit('best_chosen ~ gamma',
                           random=['gamma|dataset'],
                           categorical=['dataset'],
                           samples=n_samples,
                           chains=2)
    summary_f = result_f.summary(ranefs=True)
    summary_f.loc['gamma', 'P(>0)'] = np.mean(model_f.backend.trace.get_values('gamma') > 0)
    summary_f.to_csv(result_file)
else:
    print('Loading previous results from "{}"...'.format(result_file))
    summary_f = pd.read_csv(result_file, index_col=0)
summary_f
plot_path = os.path.join('results', 'mixed_effects_models', 'si2_parameter_behavior_f_gamma_best_chosen_posteriorplot.png')
if not os.path.isfile(plot_path):
    plot_posterior(model_f.backend.trace, varnames=['gamma'], ref_val=0, color='lightblue', point_estimate='mode');
    plt.savefig(plot_path, dpi=330)
else:
    print('Results loaded from: {}'.format(plot_path))
    show_img(plot_path)
result_file = os.path.join('results', 'mixed_effects_models', 'si2_parameter_behavior_g_gamma_gaze_influence.csv')

if not os.path.isfile(result_file):
    model_g = Model(df)
    result_g = model_g.fit('gaze_influence ~ gamma',
                           random=['gamma|dataset'],
                           categorical=['dataset'],
                           samples=n_samples,
                           chains=2)
    summary_g = result_g.summary(ranefs=True)
    summary_g.to_csv(result_file)
else:
    print('Loading previous results from "{}"...'.format(result_file))
    summary_g = pd.read_csv(result_file, index_col=0)
summary_g<jupyter_output>Loading previous results from "results/mixed_effects_models/si2_parameter_behavior_g_gamma_gaze_influence.csv"...<jupyter_text>Figure SI 2<jupyter_code>def figure_si_2(waic, 
                pred_multiplicative_summary, pred_additive_summary, 
                estimates, odd_summary, summary_e, summary_f, summary_g, 
                figsize=cm2inch(18, 18)):
    
    fig = plt.figure(figsize=figsize)
    
    ax0 = plt.subplot2grid((3, 3), (0, 0), colspan=3)
    ax1 = plt.subplot2grid((3, 3), (1, 0))
    ax2 = plt.subplot2grid((3, 3), (1, 1))
    ax3 = plt.subplot2grid((3, 3), (1, 2))
    ax4 = plt.subplot2grid((3, 3), (2, 0))
    ax5 = plt.subplot2grid((3, 3), (2, 1))
    ax6 = plt.subplot2grid((3, 3), (2, 2))
    
    figure_si_2a(waic, ylim=(-5, 5), ax=ax0)
    figure_si_2bcd(pred_multiplicative_summary, pred_additive_summary, axs=np.array([ax1, ax2, ax3]), plot_legend=False)
    figure_si_2efg(estimates, odd_summary, axs=np.array([ax4, ax5, ax6]), plot_legend=False)
    
    add_regression_line(ax4, summary_e.loc['Intercept', 'mean'], summary_e.loc['log_v', 'mean'], linewidth=1)
    add_regression_line(ax5, summary_f.loc['Intercept', 'mean'] / 100, summary_f.loc['gamma', 'mean'] / 100, linewidth=1)
    add_regression_line(ax6, summary_g.loc['Intercept', 'mean'] / 100, summary_g.loc['gamma', 'mean'] / 100, linewidth=1)
    
    fig.tight_layout()
    
    return fig, [ax0, ax1, ax2, ax3, ax4, ax5, ax6]
figure_si_2(waic,
            pred_multiplicative_summary, pred_additive_summary, 
            estimates, odd_summary, summary_e, summary_f, summary_g,
            figsize=cm2inch(18.8, 18.8))
plt.savefig('results/figures/si_figure_2_multiplicative_vs_additive.png', dpi=330, bbox_inches='tight')
plt.savefig('results/figures/si_figure_2_multiplicative_vs_additive.pdf', dpi=330, bbox_inches='tight')
plt.show()<jupyter_output><empty_output><jupyter_text>Bias Anlaysis: Multiplicative vs additive (b - d)<jupyter_code># Prepare data for mixed model
mean_rt = np.concatenate([pred_multiplicative_summary['rt']['mean'].values,
                          pred_additive_summary['rt']['mean'].values],
                         axis=0)
best_chosen = np.concatenate([pred_multiplicative_summary['best_chosen']['mean'].values,
                              pred_additive_summary['best_chosen']['mean'].values],
                             axis=0)
gaze_influence = np.concatenate([pred_multiplicative_summary['gaze_influence']['Unnamed: 10_level_1'].values,
                                 pred_additive_summary['gaze_influence']['Unnamed: 10_level_1'].values],
                                axis=0)

is_pred = np.concatenate([np.zeros(len(pred_multiplicative_summary)),
                          np.ones(len(pred_additive_summary))],
                         axis=0)
dataset = np.concatenate([pred_multiplicative_summary['dataset']['Unnamed: 11_level_1'].values,
                          pred_additive_summary['dataset']['Unnamed: 11_level_1'].values],
                         axis=0)

df = pd.DataFrame(dict(mean_rt=mean_rt,
                       best_chosen=best_chosen,
                       gaze_influence=gaze_influence,
                       is_pred=is_pred,
                       dataset=dataset))

df.head()
# Response time
result_file = os.path.join('results', 'mixed_effects_models', 'si2_multiplicative_vs_additive_b_bias_analysis_mean_rt.csv')
if not os.path.isfile(result_file):
    model = Model(df)
    results_mean_rt = model.fit('mean_rt ~ is_pred',
                                random=['is_pred|dataset'],
                                categorical=['dataset'],
                                samples=n_samples)
    bias_analysis_rt = results_mean_rt.summary(ranefs=True)
    bias_analysis_rt.to_csv(result_file)
else:
    bias_analysis_rt = pd.read_csv(result_file)
bias_analysis_rt
# P(choose best)
result_file = os.path.join('results', 'mixed_effects_models', 'si2_multiplicative_vs_additive_c_bias_analysis_p_choose_best.csv')
if not os.path.isfile(result_file):
    model = Model(df)
    results_best_chosen = model.fit('best_chosen ~ is_pred',
                                    random=['is_pred|dataset'],
                                    categorical=['dataset'],
                                    samples=n_samples)
    bias_analysis_best_chosen = results_best_chosen.summary(ranefs=True)
    bias_analysis_best_chosen.to_csv(result_file)
else:
    bias_analysis_best_chosen = pd.read_csv(result_file)
bias_analysis_best_chosen
# Gaze influence on P(choose | value)
result_file = os.path.join('results', 'mixed_effects_models', 'si2_multiplicative_vs_additive_d_bias_analysis_gaze_influence.csv')
if not os.path.isfile(result_file):
    model = Model(df)
    results_gaze_influence = model.fit('gaze_influence ~ is_pred',
                                       random=['is_pred|dataset'],
                                       categorical=['dataset'],
                                       samples=n_samples)
    bias_analysis_gaze_influence = results_gaze_influence.summary(ranefs=True)
    bias_analysis_gaze_influence.to_csv(result_file)
else:
    bias_analysis_gaze_influence = pd.read_csv(result_file)
bias_analysis_gaze_influence<jupyter_output>/Users/armin/anaconda3/lib/python3.5/site-packages/pandas/core/generic.py:4388: FutureWarning: Attribute 'is_copy' is deprecated and will be removed in a future version.
  object.__getattribute__(self, name)
/Users/armin/anaconda3/lib/python3.5/site-packages/pandas/core/generic.py:4389: FutureWarning: Attribute 'is_copy' is deprecated and will be removed in a future version.
  return object.__setattr__(self, name, value)
Average Loss = -127.74:  47%|████▋     | 23650/50000 [00:14<00:15, 1674.55it/s]
100%|██████████| 20500/20500 [01:45<00:00, 194.21it/s]
100%|██████████| 20500/20500 [01:52<00:00, 182.65it/s]
{'fraction_non_alphanumeric': 0.1383033623119368, 'fraction_numerical': 0.028343455996189114, 'mean_word_length': 2.6457308248914617, 'pattern_counts': {'":': 0, '<': 30, '<?xml version=': 0, '>': 33, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 35, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '7', 'dir': 'jupyter-structured-clean-dedup', 'id': '304450', 'license': 'MIT', 'n_tokens_mistral': 8885, 'n_tokens_neox': 8214, 'n_words': 1268, 'path': 'SI_2_multiplicative_vs_additive.ipynb', 'repo_name': 'athms/gaze-bias-differences', 'size': '25191'}