Exemplo n.º 1
0
# simulate different request coming into the system

from WebServer import WebServer, Request, Action

configMap = {"numberToServe": 10, "data_dir": "DATA"}
server = WebServer(configMap)
server.start(
)  # load all the data in the database, start the first model training

# now experiment
reqX1 = Request(userId='X1')
req1 = Request(userId=1)
print(reqX1)
print(req1)

recX1 = server.renderRec(reqX1)  # output recommendations
print(recX1)

rec1 = server.renderRec(req1)  # output recommendations
print(rec1)

# now we start an action
action1 = Action(1, 255, 5)  # user 1 rated item 255 as score 5
print(server.getFromInventory(255))  # find out the name of item 255
server.getAction(action1)  # feed the action to the server
rec1_afteraction = server.renderRec(
    req1)  # get recommendation after the system knows about the action
print(rec1_afteraction)

actionX1 = Action('X1', 123,
                  5)  # anonymous user's action won't be saved in database