def iev_user_model_creator(env_ctx):
    return iev.IEvUserModel(
        env_ctx["slate_size"],
        choice_model_ctor=choice_model.MultinomialProportionalChoiceModel,
        response_model_ctor=iev.IEvResponse,
        user_state_ctor=iev.IEvUserState,
        seed=env_ctx["seed"])
 def setUp(self):
     super(InterestEvolutionTest, self).setUp()
     self._user_model = interest_evolution.IEvUserModel(
         slate_size=1,
         choice_model_ctor=choice_model.MultinomialLogitChoiceModel,
         seed=0,
         no_click_mass=0)
     self._user_model.choice_model = FakeChoiceModel(scores=[2],
                                                     score_no_click=0,
                                                     select_index=0)
Example #3
0
  def test_slate_indices_and_length(self):
    # Initialize agent
    slate_size = 2
    num_candidates = 100
    action_space = spaces.MultiDiscrete(num_candidates * np.ones((slate_size,)))

    user_model = iev.IEvUserModel(
        slate_size,
        choice_model_ctor=choice_model.MultinomialLogitChoiceModel,
        response_model_ctor=iev.IEvResponse)
    agent = random_agent.RandomAgent(action_space, random_seed=0)

    # Create a set of documents
    document_sampler = iev.IEvVideoSampler()
    ievenv = environment.Environment(user_model, document_sampler,
                                     num_candidates, slate_size)

    # Test that slate indices in correct range and length is correct
    observation, documents = ievenv.reset()
    slate = agent.step(1, dict(user=observation, doc=documents))
    self.assertLen(slate, slate_size)
    self.assertAllInSet(slate, range(num_candidates))
Example #4
0
  def test_step(self):
    # Create a simple user
    slate_size = 2
    user_model = iev.IEvUserModel(
        slate_size,
        choice_model_ctor=choice_model.MultinomialLogitChoiceModel,
        response_model_ctor=iev.IEvResponse)

    # Create a candidate_set with 5 items
    num_candidates = 5
    document_sampler = iev.IEvVideoSampler()
    ievsim = environment.Environment(user_model, document_sampler,
                                     num_candidates, slate_size)

    # Create agent
    action_space = spaces.MultiDiscrete(num_candidates * np.ones((slate_size,)))
    agent = random_agent.RandomAgent(action_space, random_seed=0)

    # This agent doesn't use the previous user response
    observation, documents = ievsim.reset()
    slate = agent.step(1, dict(user=observation, doc=documents))
    self.assertAllEqual(slate, [2, 0])
Example #5
0
if __name__ == '__main__':
    from recsim.environments import interest_evolution

    slate_size = 3
    num_candidates = 10
    env_config = {
        'num_candidates': 5,
        'slate_size': slate_size,
        'resample_documents': True,
        'seed': 0,
    }

    tmp_base_dir = 'C:/Users/Moham/PycharmProjects/ExpertDrivenRec/'

    user_model = interest_evolution.IEvUserModel(
        slate_size,
        choice_model_ctor=choice_model.MultinomialProportionalChoiceModel,
        response_model_ctor=interest_evolution.IEvResponse,
        user_state_ctor=interest_evolution.IEvUserState,
        seed=0)

    expertEnv = environment.Environment(ExpertModel(slate_size),
                                        EEVideoSampler(),
                                        num_candidates,
                                        slate_size,
                                        resample_documents=True)
    steps = 10
    traj, states = generate_trajectories(expertEnv, 3, steps, num_candidates,
                                         slate_size)