Exemple #1
0
CSV_FOLDER, CSV_ALL, CONFIG_FILE, Q_NPZ, SKILL_WINS, SKILL_FAILS = dataio.build_new_paths(
    DATASET_NAME)

config = dataio.get_config(CONFIG_FILE)
experiment_args = vars(options)

df_train, df_val, df_test = dataio.get_data(DATASET_NAME)
try:
    skill_wins = load_npz(SKILL_WINS)
    skill_fails = load_npz(SKILL_FAILS)
except:
    skill_wins = None
    skill_fails = None

short_legend, full_legend, latex_legend, active_agents = dataio.get_legend(
    experiment_args)
EXPERIMENT_FOLDER = os.path.join(CSV_FOLDER, short_legend)
dataio.prepare_folder(EXPERIMENT_FOLDER)


def df_to_sparse(df, filename):
    SPARSE_NPZ = os.path.join(EXPERIMENT_FOLDER, filename)
    if os.path.isfile(SPARSE_NPZ):
        X_fm = load_npz(SPARSE_NPZ)
        return X_fm
    X = {}
    nb_events, _ = df.shape
    rows = list(range(nb_events))
    for key in ['users', 'items', 'speech']:
        X[key] = coo_matrix(([1] * nb_events, (rows, df[key])),
                            shape=(nb_events, config['NUM'][key]))
Exemple #2
0
    # Tables
    labels = {}
    latex_labels = {}
    TABLE_TEX = os.path.join(CSV_FOLDER, '{:s}-table.tex'.format(DATASET_NAME))
    array = []
    acc_values = {}
    nll_values = {}
    #with open(TABLE_TEX, 'w') as latex:
    for filename in experiments:
        df = pd.read_csv(filename.replace('results.json', 'rlog.csv'))
        acc_values[filename] = df['accuracy']
        nll_values[filename] = df['ll_mcmc_all']
        with open(filename) as f:
            results = json.load(f)
        short_legend, full_legend, latex_legend, active_agents = dataio.get_legend(
            results['args'])
        # full_legend = full_legend
        latex_legend = latex_legend.replace(
            'users, items, skills, wins, fails, item_wins, item_fails',
            'u, i, s, w, f, item_wins, item_fails').replace('_', r'\_')
        print(filename)
        print(latex_legend)
        labels[filename] = full_legend
        latex_labels[filename] = latex_legend + " $d = {:d}$".format(
            results['args']['d'])
        # line = '{:s} & '.format(latex_legend)
        # line += ' & '.join('{:.4f}'.format(results['metrics'][metric]) for metric in ['ACC', 'AUC', 'NLL']) + r'\\'
        row = [latex_legend, results['args']['d']] + [
            results['metrics'][metric] for metric in ['ACC', 'AUC', 'NLL']
        ]
        # MCMC NLL is different