# Path: babyai/plotting.py
# def load_log(dir_):
# def load_multiphase_log(dir_):
# def load_logs(root, multiphase=False):
# def plot_average_impl(df, regexps, y_value='return_mean', window=1, agg='mean',
#                       x_value='frames'):
# def plot_average(*args, **kwargs):
# def plot_all_runs(df, regex, quantity='return_mean', x_axis='frames', window=1, color=None):
# def model_num_samples(model):
# def get_fps(df):
# def best_within_normal_time(df, regex, patience, limit='epochs', window=1, normal_time=None, summary_path=None):
# def estimate_sample_efficiency(df, visualize=False, figure_path=None):


import argparse
import pandas
import os
import json
from babyai import plotting
#!/usr/bin/env python3




parser = argparse.ArgumentParser("Analyze data efficiency of imitation learning")
parser.add_argument('--path', default='.')
parser.add_argument("--regex", default='.*')
parser.add_argument("--patience", default=2, type=int)
parser.add_argument("--window", default=1, type=int)
parser.add_argument("--limit", default="frames")
parser.add_argument("report")
args = parser.parse_args()

if os.path.exists(args.report):
    raise ValueError("report directory already exists")
os.mkdir(args.report)

summary_path = os.path.join(args.report, 'summary.csv')
figure_path = os.path.join(args.report, 'visualization.png')
result_path = os.path.join(args.report, 'result.json')

df_logs = pandas.concat(plotting.load_logs(args.path), sort=True)

# Path: babyai/plotting.py
# def load_log(dir_):
# def load_multiphase_log(dir_):
# def load_logs(root, multiphase=False):
# def plot_average_impl(df, regexps, y_value='return_mean', window=1, agg='mean',
#                       x_value='frames'):
# def plot_average(*args, **kwargs):
# def plot_all_runs(df, regex, quantity='return_mean', x_axis='frames', window=1, color=None):
# def model_num_samples(model):
# def get_fps(df):
# def best_within_normal_time(df, regex, patience, limit='epochs', window=1, normal_time=None, summary_path=None):
# def estimate_sample_efficiency(df, visualize=False, figure_path=None):


# Path: scripts/il_dataeff.py
import argparse
import pandas
import os
import json
from babyai import plotting

#!/usr/bin/env python3




parser = argparse.ArgumentParser("Analyze data efficiency of imitation learning")
parser.add_argument('--path', default='.')
parser.add_argument("--regex", default='.*')
parser.add_argument("--patience", default=2, type=int)
parser.add_argument("--window", default=1, type=int)
parser.add_argument("--limit", default="frames")
parser.add_argument("report")
args = parser.parse_args()

if os.path.exists(args.report):
    raise ValueError("report directory already exists")
os.mkdir(args.report)

summary_path = os.path.join(args.report, 'summary.csv')
figure_path = os.path.join(args.report, 'visualization.png')
result_path = os.path.join(args.report, 'result.json')

df_logs = pandas.concat(plotting.load_logs(args.path), sort=True)

df_success_rate, normal_time = plotting.best_within_normal_time(