def write_per_claim_analysis(*, df,
                             claim_lookup,
                             output_path):
  """For each claim, write the examples the model scored and claim summary.

  Args:
    df: Dataframe to read predictions and examples from
    claim_lookup: Lookup from claim_id to fever claim dictionary
    output_path: Path to write analysis to
  """
  claim_predictions = {}
  grouped_df = df.groupby(['scrape_type', 'claim_id'])
  for (scrape_type, claim_id), claim_df in tqdm.tqdm(
      grouped_df, mininterval=10):
    label = claim_lookup[claim_id]['label']
    claim_df = claim_df.sort_values('model_score', ascending=False)
    claim_df = claim_df[[
        'gold', 'tfidf_candidate', 'model_score', 'support_score',
        'refute_score', 'nei_score', 'wikipedia_url', 'sentence_id',
        'evidence_text'
    ]]
    recall_rank = sys.maxsize
    for rank, row in enumerate(claim_df.itertuples(), start=1):
      if row.gold:
        recall_rank = rank
        break

    claim_predictions[(scrape_type, claim_id)] = {
        'df': claim_df,
        'claim_id': claim_id,
        'scrape_type': scrape_type,
        'label': label,
        'rank': recall_rank,
    }

  with util.safe_open(output_path, 'wb') as f:
    pickle.dump(claim_predictions, f)
For each claim, write the examples the model scored and claim summary.

  Args:
    df: Dataframe to read predictions and examples from
    claim_lookup: Lookup from claim_id to fever claim dictionary
    output_path: Path to write analysis to
  
language/serene/analysis.py