def setUp(self): super(AgentTest, self).setUp() self.data_dir = os.path.join( FLAGS.test_srcdir, os.path.split(os.path.abspath(__file__))[0], 'test_data') self.seeds = movie_lens_simulator.Seeds(user_model=0, user_sampler=0, train_eval_test=0) self.user_config = movie_lens_simulator.UserConfig(accept_prob=0.5, diversity_prob=0.5) self.env_config = movie_lens_simulator.EnvConfig( data_dir=self.data_dir, embeddings_path=f'{self.data_dir}/embeddings.json', genre_history_path=f'{self.data_dir}/genre_history.json', seeds=self.seeds, slate_size=5, user_config=self.user_config) self.df = generate_data.generate_data(self.env_config, slate_type='test', n_samples=50, seed=0, intercept=-5., rating_coef=1., div_seek_coef=3., diversity_coef=-0.5)
def setUp(self): super(MovieLensTestNoShift, self).setUp() self.data_dir = os.path.join(FLAGS.test_srcdir, os.path.split(os.path.abspath(__file__))[0], 'test_data') self.env_config = movie_lens.EnvConfig( seeds=movie_lens.Seeds(0, 0), data_dir=self.data_dir, genre_history_path=os.path.join(self.data_dir, 'genre_history.json'), embeddings_path=os.path.join(self.data_dir, 'embeddings.json'), genre_shift=None, bias_against_unseen=0.) self._initialize_from_config(self.env_config)
def main(argv): if len(argv) > 1: raise app.UsageError('Too many command-line arguments.') seeds = movie_lens_simulator.Seeds(user_model=FLAGS.global_seed, user_sampler=FLAGS.global_seed, train_eval_test=FLAGS.global_seed) user_config = movie_lens_simulator.UserConfig( accept_prob=FLAGS.accept_prob, diversity_prob=FLAGS.diversity_prob) # TODO(moberst): genre_shift should be passed in here, not calculated # within the generate_data function env_config = movie_lens_simulator.EnvConfig( data_dir=FLAGS.data_directory, embeddings_path=f'{FLAGS.data_directory}/{FLAGS.embedding_file}', genre_history_path=f'{FLAGS.data_directory}/{FLAGS.genre_history_file}', seeds=seeds, user_config=user_config, bias_against_unseen=0.) if FLAGS.agent_file_str: agent_file = f'{FLAGS.agent_directory}/{FLAGS.agent_file_str}.pkl' recommender_agent = agent.load_agent(agent_file) agent_str = FLAGS.agent_file_str else: # If None, this will be populated with a random agent in generate_data recommender_agent = None agent_str = 'random-agent' df = generate_data(env_config=env_config, slate_type=FLAGS.slate_type, n_samples=FLAGS.n_samples, seed=FLAGS.global_seed, intercept=FLAGS.intercept, rating_coef=FLAGS.rating_coef, div_seek_coef=FLAGS.div_seek_coef, diversity_coef=FLAGS.diversity_coef, recommender_agent=recommender_agent, shift=FLAGS.shift, user_pool=FLAGS.user_pool) write_csv_output(dataframe=df, filename=(f'simulation_results' f'_{FLAGS.n_samples}' f'_{FLAGS.slate_type}' f'_{FLAGS.accept_prob}' f'_{FLAGS.user_pool}' f'_{agent_str}' f'{"_shift" if FLAGS.shift != 0. else ""}' '.csv'), directory=FLAGS.output_directory)
def setUp(self): super(GenerateDataTest, self).setUp() self.data_dir = os.path.join(FLAGS.test_srcdir, os.path.split(os.path.abspath(__file__))[0], 'test_data') self.seeds = movie_lens_simulator.Seeds( user_model=0, user_sampler=0, train_eval_test=0) self.user_config = movie_lens_simulator.UserConfig( accept_prob=0.5, diversity_prob=0.5) self.env_config = movie_lens_simulator.EnvConfig( data_dir=self.data_dir, embeddings_path=f'{self.data_dir}/embeddings.json', genre_history_path=f'{self.data_dir}/genre_history.json', seeds=self.seeds, slate_size=5, user_config=self.user_config)