Exemplo n.º 1
0
def test02():
    print("Test 02")

    rDescr: RecommenderDescription = InputRecomRRDefinition.exportRDescTheMostPopular(
    )
    recommenderID: str = InputRecomRRDefinition.THE_MOST_POPULAR

    rDescr: RecommenderDescription = InputRecomRRDefinition.exportRDescKNN()
    recommenderID: str = InputRecomRRDefinition.KNN

    rDescr: RecommenderDescription = InputRecomRRDefinition.exportRDescBPRMFIMPL(
    )
    recommenderID: str = InputRecomRRDefinition.BPRMFIMPL

    rDescr: RecommenderDescription = InputRecomRRDefinition.exportRDescVMContextKNN(
    )
    recommenderID: str = InputRecomRRDefinition.VMC_KNN

    rDescr: RecommenderDescription = InputRecomRRDefinition.exportRDescCosineCB(
    )
    recommenderID: str = InputRecomRRDefinition.COSINECB

    rDescr: RecommenderDescription = InputRecomRRDefinition.exportRDescW2V()
    recommenderID: str = InputRecomRRDefinition.W2V

    pDescr: Portfolio1MethDescription = Portfolio1MethDescription(
        recommenderID.title(), recommenderID, rDescr)

    dataset: ADataset = DatasetRetailRocket.readDatasetsWithFilter(
        minEventCount=50)

    behavioursDF: DataFrame = BehavioursRR.readFromFileRR(
        BehavioursRR.getFile("static08"))

    history: AHistory = HistoryDF("test")
    p: APortfolio = pDescr.exportPortfolio("jobID", history)
    p.train(history, dataset)

    argsSimulationDict: Dict[str, str] = {
        SimulationRR.ARG_WINDOW_SIZE: 50,
        SimulationRR.ARG_RECOM_REPETITION_COUNT: 1,
        SimulationRR.ARG_NUMBER_OF_RECOMM_ITEMS: 100,
        SimulationRR.ARG_NUMBER_OF_AGGR_ITEMS:
        InputSimulatorDefinition.numberOfAggrItems,
        SimulationRR.ARG_DIV_DATASET_PERC_SIZE: 90,
        SimulationRR.ARG_HISTORY_LENGTH: 10
    }

    # simulation of portfolio
    simulator: Simulator = Simulator("test", SimulationRR, argsSimulationDict,
                                     dataset, behavioursDF)
    simulator.simulate([pDescr], [DataFrame()], [EToolDoNothing({})],
                       [HistoryHierDF("a")])
            intersectionI: List[int] = [
                value for value in itemIDs if value in recommendationI
            ]
            #print("   " + str(len(intersectionI)))
            counter += len(intersectionI)

        print("  counter: " + str(counter))


if __name__ == "__main__":
    os.chdir("..")

    dataset: ADataset = DatasetRetailRocket.readDatasetsWithFilter(
        minEventCount=50)

    rDscrTheMostPopular: RecommenderDescription = InputRecomRRDefinition.exportRDescTheMostPopular(
    )
    rDscrItemBasedKNN: RecommenderDescription = InputRecomRRDefinition.exportRDescKNN(
    )
    rDscrBPRMF: RecommenderDescription = InputRecomRRDefinition.exportRDescBPRMFIMPL(
    )
    rDscrVMContextKNN: RecommenderDescription = InputRecomRRDefinition.exportRDescVMContextKNN(
    )
    rDscrCosineCB: RecommenderDescription = InputRecomRRDefinition.exportRDescCosineCB(
    )
    rDscrW2V: RecommenderDescription = InputRecomRRDefinition.exportRDescW2V()

    rDscrs: List[object] = [
        rDscrTheMostPopular, rDscrItemBasedKNN, rDscrBPRMF, rDscrVMContextKNN,
        rDscrCosineCB, rDscrW2V
    ]
    rDscrs: List[object] = [rDscrW2V]