Skip to content

Bug in def get_predictions(parameter, outfile): #19

@lollotala

Description

@lollotala

There is an iteration in the original definition that is looping while calling always the first row to estimate mean and SD of prediction.

Replace with following:

def get_predictions(parameter, outfile):
    df = pd.read_csv(outfile)
    pred_col = []
    pred_logcol = []
    pred_sd_totcol = []
    pred_sd_aleacol = []
    pred_sd_epicol = []
    
    for ii in  range(df.shape[0]):
        unit = 'mM'
        if parameter=='kcat':
            parameter_print = 'k_{cat}'
            parameter_print_log = 'log_{10}(k_{cat})'
            target_col = 'log10kcat_max'
            unit = 's^(-1)'
        elif parameter=='km':
            target_col = 'log10km_mean'
            parameter_print = 'K_{m}'
            parameter_print_log = 'log_{10}(K_{m})'
        else:
            target_col = 'log10ki_mean'
            parameter_print = 'K_{i}'
            parameter_print_log = 'log_{10}(K_{i})'
    
        unc_col = f'{target_col}_mve_uncal_var'
        model_cols = [col for col in df.columns if col.startswith(target_col) and 'model_' in col]
    
        unc = df[unc_col].iloc[ii]
    
        prediction = df[target_col].iloc[ii]
        prediction_linear = np.power(10, prediction)
    
        model_out = df[target_col].iloc[ii]
        model_outs = np.array([df[col].iloc[ii] for col in model_cols])
        # print(model_outs)
        epi_unc = np.var(model_outs)#np.sum(np.power(2, model_outs))/10. - np.power(2, model_out)
        alea_unc = unc - epi_unc
        epi_unc = np.sqrt(epi_unc)
        alea_unc = np.sqrt(alea_unc)
        unc = np.sqrt(unc)
        
        # print(unc-epi_unc-alea_unc)
        # def display_outs(prediction_type, out, alea_output, epi_output, unit):
        pred_col.append(prediction_linear)
        pred_logcol.append(prediction)
        pred_sd_totcol.append(unc)
        pred_sd_aleacol.append(alea_unc)
        pred_sd_epicol.append(epi_unc)

    df[f'Prediction_({unit})'] = pred_col
    df['Prediction_log10'] = pred_logcol
    df['SD_total'] = pred_sd_totcol
    df['SD_aleatoric'] = pred_sd_aleacol
    df['SD_epistemic'] = pred_sd_epicol

    return df

output_final = get_predictions(parameter, outfile)
output_final.to_csv(f'{outfile}')
print('Output saved to', outfile)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions