google-research/rliable

Add support for loading data from pandas dataframe

Open

#18 aperta il 18 gen 2023

Vedi su GitHub
 (2 commenti) (0 reazioni) (0 assegnatari)Jupyter Notebook (49 fork)auto 404
enhancementgood first issuehelp wanted

Metriche repository

Star
 (875 star)
Metriche merge PR
 (Metriche PR in attesa)

Descrizione

Right now, we only support loading data from numpy arrays. It would be nice if there was a helper function to convert a dataframe of scores to numpy arrays. Some initial code to help what this might look like:


def get_all_return_values(df):
  games = list(df['game'].unique())
  return_vals = {}
  for game in games:
    game_df = df[df['game'] == game]
    arr = game_df.groupby('wid')['normalized_score'].apply(list).values
    return_vals[game] = np.stack(arr, axis=0)
  return return_vals

def convert_to_matrix(x):
  return np.stack([x[k] for k in sorted(x.keys())], axis=1)

## Usage
# Array of shape (num_runs, num_games, num_steps)`
all_normalized_scores = convert_to_matrix(get_all_return_values(score_df))

The above code assumes we have a pandas Dataframe with keys run_number, 'gameandnormalized_score` containing scores for all steps (in a ordered manner).

Guida contributor