Exemplo n.º 1
0
# 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
print(server.getFromInventory(123))
server.getAction(actionX1)
recX1_afteraction = server.renderRec(reqX1)
print(recX1_afteraction)

# update the system, e.g. one day has passed
server.increment()
# the system should forget about actionX1