示例#1
0
def test02():
    print("Test 02")

    print("Running RecommenderCosineCB RR:")

    dataset: DatasetST = DatasetRetailRocket.readDatasets()

    args: dict = {
        RecommenderCosineCB.ARG_CB_DATA_PATH:
        Configuration.cbRRDataFileWithPathOHE,
        RecommenderCosineCB.ARG_USER_PROFILE_SIZE: 5,
        RecommenderCosineCB.ARG_USER_PROFILE_STRATEGY: "max",
        RecommenderCosineCB.ARG_USE_DIVERSITY: False,
    }  #True
    rec: ARecommender = RecommenderCosineCB("test", args)

    rec.train(HistoryDF("test"), dataset)

    eventsDFDFUpdate: DataFrame = dataset.eventsDF.iloc[5003:5004]

    print(eventsDFDFUpdate)
    rec.update(eventsDFDFUpdate, args)

    # user with very outdated profile - no recent objects
    r: Series = rec.recommend(863743, 20, args)
    print(type(r))
    print(r)

    # testing of a non-existent user
    r: Series = rec.recommend(10000, 50, args)
    print(type(r))
    print(r)
示例#2
0
def test11():

    print("Simulation: RR TheMostPopular")

    rDescr:RecommenderDescription = InputRecomMLDefinition.exportRDescTheMostPopular()

    pDescr:APortfolioDescription = Portfolio1MethDescription(InputRecomMLDefinition.THE_MOST_POPULAR.title(),
                                                             InputRecomMLDefinition.THE_MOST_POPULAR, rDescr)

    batchID:str = "retailrocketDiv90Ulinear0109R1"
    dataset:DatasetRetailRocket = DatasetRetailRocket.readDatasets()
    behaviourFile:str = BehavioursRR.getFile(BehavioursRR.BHVR_LINEAR0109)
    behavioursDF:DataFrame = BehavioursRR.readFromFileRR(behaviourFile)

    # simulation of portfolio
    simulator:Simulator = Simulator(batchID, SimulationRR, argsSimulationDict, dataset, behavioursDF)
    simulator.simulate([pDescr], [DataFrame()], [EToolDoNothing({})], [HistoryHierDF(pDescr.getPortfolioID())])