src/baselines/results.py
def process_preds_base(df, info):
  """ Processes all Predictions into Longform DF with Dataset Examples + Correct Tags.

  """
  dfp = to_wide_rankings(df)
  dfp = dfp[[('example_idx', ''), ('model_name', ''), ('pred_idx', 'final')]]
  dfp.columns = dfp.columns.droplevel(1)
  # add unifiedqa
  uqa_df = df[df['model_name'].apply(lambda x: x.startswith('allenai'))]
  if len(uqa_df.index) > 0:
    # uqa_df = uqa_df[['example_idx', 'model_name', 'pred_idx', 'generated']]
    uqa_df = uqa_df[['example_idx', 'model_name', 'pred_idx']]
    dfp = pd.concat([dfp, uqa_df])
  # add info
  dfm = dfp.merge(info, on='example_idx', how='left')
  # get correct (per example)
  dfm['correct'] = dfm['pred_idx'] == dfm['label']
  # get groupings
  dfm['question_group'] = dfm['name'].apply(
    lambda x: x.split('_')[0].replace('non', ''))
  return dfm
 Processes all Predictions into Longform DF with Dataset Examples + Correct Tags.

  
Processes all Predictions into Longform DF with Dataset Examples + Correct Tags.
Processes all Predictions into Longform DF with Dataset Examples + Correct Tags .
def process_preds_base(df, info):
  dfp = to_wide_rankings(df)
  dfp = dfp[[('example_idx', ''), ('model_name', ''), ('pred_idx', 'final')]]
  dfp.columns = dfp.columns.droplevel(1)
  uqa_df = df[df['model_name'].apply(lambda x: x.startswith('allenai'))]
  if len(uqa_df.index) > 0:
    uqa_df = uqa_df[['example_idx', 'model_name', 'pred_idx']]
    dfp = pd.concat([dfp, uqa_df])
  dfm = dfp.merge(info, on='example_idx', how='left')
  dfm['correct'] = dfm['pred_idx'] == dfm['label']
  dfm['question_group'] = dfm['name'].apply(
    lambda x: x.split('_')[0].replace('non', ''))
  return dfm
def process_preds_base ( df , info ) : dfp = to_wide_rankings ( df ) dfp = dfp [ [ ( 'example_idx' , '' ) , ( 'model_name' , '' ) , ( 'pred_idx' , 'final' ) ] ] dfp . columns = dfp . columns . droplevel ( 1 ) uqa_df = df [ df [ 'model_name' ] . apply ( lambda x : x . startswith ( 'allenai' ) ) ] if len ( uqa_df . index ) > 0 : uqa_df = uqa_df [ [ 'example_idx' , 'model_name' , 'pred_idx' ] ] dfp = pd . concat ( [ dfp , uqa_df ] ) dfm = dfp . merge ( info , on = 'example_idx' , how = 'left' ) dfm [ 'correct' ] = dfm [ 'pred_idx' ] == dfm [ 'label' ] dfm [ 'question_group' ] = dfm [ 'name' ] . apply ( lambda x : x . split ( '_' ) [ 0 ] . replace ( 'non' , '' ) ) return dfm
Processes all Predictions into Longform DF with Dataset Examples + Correct Tags.
Processes all Predictions into Longform DF with Dataset Examples + Correct Tags .
""" Processes all Predictions into Longform DF with Dataset Examples + Correct Tags.

  """ # add unifiedqa # uqa_df = uqa_df[['example_idx', 'model_name', 'pred_idx', 'generated']] # add info # get correct (per example) # get groupings
df
info