def run_and_output()

in isoexp/devfair_reward_attack.py [0:0]


def run_and_output(dataset=None):
    results = []
    if PARALLEL:
        import multiprocessing

        num_cores = multiprocessing.cpu_count()
        results = Parallel(n_jobs=num_cores, verbose=1)(
            delayed(work)(m=m, nb_arms=K, nb_features=n_features, noise=a_noise,
                          nb_simu=nb_simu, T=T, all_algs=algorithms,
                          random_state=random_state + m, M=M, which=dataset) for m in range(nb_models))

    else:

        for m in tqdm(range(nb_models)):
            ret = work(m, K, n_features, a_noise, nb_simu, T, algorithms, random_state + m, M=M)
            results.append(ret)
    id = '{:%Y%m%d_%H%M%S}'.format(datetime.datetime.now())
    pickle_name = "{}_{}_{}_contextual_attacks_rewards.pickle".format(dataset, id, "PAR" if PARALLEL else "SEQ")
    print(pickle_name)
    with open(pickle_name, "wb") as f:
        pickle.dump(results, f)
    with open("{}_{}_{}_contextual_attacks_rewards_settings.json".format(dataset, id, "PAR" if PARALLEL else "SEQ"), "w+") as f:
        json.dump(settings, f)
    return results, pickle_name, id,