generate.py
def eval_model(mind, test_dataset, df, vocabBoost, mtd='para'):
    '''
    get generated sentence for a particular model
    '''
    finaldf = pd.DataFrame()
    if mtd == 'para':
        savedir = './modelp/savedmodels'
    elif mtd == 'joint':
        savedir = './modelmix/savedmodels'
    else:
        savedir = './modelr/savedmodels'

    if 'orisen' in df.columns:
        colsen = 'orisen'
    else:
        colsen = 'sen'
    modelpath = savedir + str(mind)
    print(modelpath)
    model = OpenAIGPTLMHeadModel.from_pretrained(modelpath)
    model.to(device_dr)
    model.eval()
    df = repeatN(df, len(ps) - 1)
    outlist, outp = gen_p(model, test_dataset, df['descat'].tolist(), vocabBoost)
    df['out'] = outlist
    df['p-value'] = outp
    df.sort_values(by=[colsen, 'p-value'], inplace=True)
    df['modelind'] = mind
    finaldf = finaldf.append(df, ignore_index=True)
    return finaldf

    get generated sentence for a particular model
    
get generated sentence for a particular model
get generated sentence for a particular model
def eval_model(mind, test_dataset, df, vocabBoost, mtd='para'):
    finaldf = pd.DataFrame()
    if mtd == 'para':
        savedir = './modelp/savedmodels'
    elif mtd == 'joint':
        savedir = './modelmix/savedmodels'
    else:
        savedir = './modelr/savedmodels'
    if 'orisen' in df.columns:
        colsen = 'orisen'
    else:
        colsen = 'sen'
    modelpath = savedir + str(mind)
    print(modelpath)
    model = OpenAIGPTLMHeadModel.from_pretrained(modelpath)
    model.to(device_dr)
    model.eval()
    df = repeatN(df, len(ps) - 1)
    outlist, outp = gen_p(model, test_dataset, df['descat'].tolist(), vocabBoost)
    df['out'] = outlist
    df['p-value'] = outp
    df.sort_values(by=[colsen, 'p-value'], inplace=True)
    df['modelind'] = mind
    finaldf = finaldf.append(df, ignore_index=True)
    return finaldf
def eval_model ( mind , test_dataset , df , vocabBoost , mtd = 'para' ) : finaldf = pd . DataFrame ( ) if mtd == 'para' : savedir = './modelp/savedmodels' elif mtd == 'joint' : savedir = './modelmix/savedmodels' else : savedir = './modelr/savedmodels' if 'orisen' in df . columns : colsen = 'orisen' else : colsen = 'sen' modelpath = savedir + str ( mind ) print ( modelpath ) model = OpenAIGPTLMHeadModel . from_pretrained ( modelpath ) model . to ( device_dr ) model . eval ( ) df = repeatN ( df , len ( ps ) - 1 ) outlist , outp = gen_p ( model , test_dataset , df [ 'descat' ] . tolist ( ) , vocabBoost ) df [ 'out' ] = outlist df [ 'p-value' ] = outp df . sort_values ( by = [ colsen , 'p-value' ] , inplace = True ) df [ 'modelind' ] = mind finaldf = finaldf . append ( df , ignore_index = True ) return finaldf
get generated sentence for a particular model
get generated sentence for a particular model
'''
    get generated sentence for a particular model
    '''
mind
test_dataset
df
vocabBoost
mtd