Getting Started

Getting Started

On your own system follow the install instructions to install RecoGym here, do both a pip install and clone the repo.

Download the starting kit from here and extract it into the reco-gym directory.


Then..

cd reco-gym

You can produce your own leaderboard using our in built agents by running:

python sim_test.py --P=10 --F=5 --U=100 --Utest=1000 --entries_dir='leaderboard_entries' --seed=42

This script will use 10 products with 100 user sessions for training and 100 user sessions for testing for every agent in the "entries" subdirectory. It will write a file entries_10_100_100_TIMESTAMP/leaderboard.csv. You can inspect this file to see how each agent performed for this test. All of the agents found within the entries subdirectory are imported directly from RecoGym and as such are merely stubs (also many of them do not scale to large numbers of products).

There is a complete agent implemented in the myagents subdirectory which you can simulate an A/B test by running:

python sim_test.py --P=10 --F=5 --U=100 --Utest=1000 --entries_dir='my_entries' --seed=42


You can use my_entries/challenge_entry.py as a basic agent to modify and get inspiration from more complex agents by looking in the agents subdirectory.


In order to produce a leaderboard for your entries for the 100 product competition you should run:

python sim_test.py --P=100 --F=50 --U=1000 --Utest=20000 --entries_dir='my_entries' --seed=42

but vary the value of seed to test for robust performance.


Similarly in order to produce a leaderboard for your entries for the 10000 product competition you should run:

python sim_test.py --P=10000 --F=5000 --U=1000 --Utest=20000 --entries_dir='my_entries' --seed=42

again varying the seed.


Example: Submitting a simple agent for evaluation

In order to submit an agent you must produce a .zip file containing two files.

  1. A metadata containing: "description: Compute scores for the competition"
  2. A test_agent.py file that contains an arguments variable test_agent_args which is a dict which at a minimum contains 'num_products' as a configuration for your agent, and a TestAgent class, with a constructor and an act method at a minimum (although you will want a train method too in practice. An example is given below:



import numpy as np

from numpy.random.mtrand import RandomState

from recogym.agents import Agent
from recogym import Configuration

test_agent_args = {
    'num_products': 10,
    'random_seed': np.random.randint(2 ** 31 - 1),
}

class TestAgent(Agent):

    """A Random Agent"""

    def __init__(self, config = Configuration(test_agent_args)):
        super(TestAgent, self).__init__(config)
        self.rng = RandomState(config.random_seed)

    def act(self, observation, reward, done):

return {

            **super().act(observation, reward, done),
            **{
                'a': self.rng.choice(self.config.num_products),
                'ps': 1.0 / float(self.config.num_products),
                'ps-a': np.ones(self.config.num_products) / self.config.num_products,
            },
        }


Create a subdirectory containing only these two files and then run:

zip -r -j my_entry.zip .

Then go to the CodaLab page go to "Participate" and then "Submit / View Results". Write a comment about your agent. Click submit and then upload your my_entry.zip file.


You will find other examples of agents in the starting kit and in your my_entries subdirectory. RecoGym also contains a number of examples. In order to run them you must rename the file to test_agent.py, the class to TestAgent and make sure they take the argument test_agent_args. Further note that many of these examples can be slow for large numbers of products.


Your agent must run under python3.6

Libraries available include:

  • Cython-0.29.13
  • absl-py-0.8.0
  • astor-0.8.0
  • cloudpickle-1.2.2
  • cycler-0.10.0
  • datetime-4.3
  • future-0.17.1
  • gast-0.2.2
  • google-pasta-0.1.7
  • grpcio-1.24.0
  • gym-0.14.0
  • h5py-2.10.0
  • joblib-0.13.2
  • keras-applications-1.0.8
  • keras-preprocessing-1.1.0
  • kiwisolver-1.1.0
  • llvmlite-0.29.0
  • markdown-3.1.1
  • matplotlib-3.1.1
  • numba-0.45.1
  • numpy-1.17.2 opt-einsum-3.0.1
  • pandas-0.25.1
  • protobuf-3.9.2
  • pyglet-1.3.2
  • pyparsing-2.4.2
  • pystan-2.19.0.0
  • python-dateutil-2.8.0
  • pytz-2019.2
  • recogym-0.1.1.1
  • scikit-learn-0.21.3
  • scipy-1.3.1
  • simplegeneric-0.8.1
  • six-1.12.0
  • tensorboard-2.0.0
  • tensorflow-2.0.0
  • tensorflow-estimator-2.0.0
  • termcolor-1.1.0 torch-1.2.0
  • tqdm-4.36.1
  • werkzeug-0.16.0
  • wrapt-1.11.2
  • zope.interface-4.6.0