def test21(): print("Simulation: ST BanditTS") jobID: str = "BanditTS" selector = RouletteWheelSelector({RouletteWheelSelector.ARG_EXPONENT: 1}) rIDs, rDescs = InputRecomSTDefinition.exportPairOfRecomIdsAndRecomDescrs() pDescr: Portfolio1AggrDescription = Portfolio1AggrDescription( "BanditTS" + jobID, rIDs, rDescs, InputAggrDefinition.exportADescBanditTS(selector)) batchID: str = "stDiv90Ulinear0109R1" dataset: DatasetST = DatasetST.readDatasets() behaviourFile: str = BehavioursST.getFile(BehavioursST.BHVR_LINEAR0109) behavioursDF: DataFrame = BehavioursST.readFromFileST(behaviourFile) model: DataFrame = PModelBandit(pDescr.getRecommendersIDs()) # simulation of portfolio simulator: Simulator = Simulator(batchID, SimulationST, argsSimulationDict, dataset, behavioursDF) simulator.simulate([pDescr], [model], [EvalToolBanditTS({})], [HistoryHierDF(pDescr.getPortfolioID())])
def test01(): print("Simulation: ML DHontThompsonSampling") jobID: str = "Roulette1" selector = RouletteWheelSelector({RouletteWheelSelector.ARG_EXPONENT: 1}) rIDs, rDescs = InputRecomSTDefinition.exportPairOfRecomIdsAndRecomDescrs() pDescr: Portfolio1AggrDescription = Portfolio1AggrDescription( "DHontThompsonSampling" + jobID, rIDs, rDescs, InputAggrDefinition.exportADescDHondtThompsonSampling(selector)) batchID: str = "ml1mDiv90Ulinear0109R1" dataset: DatasetML = DatasetML.readDatasets() behaviourFile: str = BehavioursML.getFile(BehavioursML.BHVR_LINEAR0109) behavioursDF: DataFrame = BehavioursML.readFromFileMl1m(behaviourFile) model: DataFrame = PModelDHondtBanditsVotes(pDescr.getRecommendersIDs()) eTool: AEvalTool = EvalToolDHondtBanditVotes({}) # simulation of portfolio simulator: Simulator = Simulator(batchID, SimulationML, argsSimulationDict, dataset, behavioursDF) simulator.simulate([pDescr], [model], [eTool], [HistoryHierDF(pDescr.getPortfolioID())])
def getFuzzyDHontINF(): #taskID:str = "Web" + "FuzzyDHondtINF" + "Roulette1" taskID:str = "Web" + "FuzzyDHondt" + "Fixed" dataset:ADataset = DatasetST.readDatasets() #selector:ADHondtSelector = RouletteWheelSelector({RouletteWheelSelector.ARG_EXPONENT: 1}) selector:ADHondtSelector = TheMostVotedItemSelector({}) pToolOLin0802HLin1002:APenalization = PenalizationToolDefinition.exportPenaltyToolOLin0802HLin1002( InputSimulatorDefinition.numberOfAggrItems) aDescDHont:AggregationDescription = InputAggrDefinition.exportADescDHondtINF(selector, pToolOLin0802HLin1002) rIDs, rDescs = InputRecomSTDefinition.exportPairOfRecomIdsAndRecomDescrs() pDescr:Portfolio1AggrDescription = Portfolio1AggrDescription( taskID, rIDs, rDescs, aDescDHont) history:AHistory = HistoryHierDF(taskID) port:APortfolio = pDescr.exportPortfolio(taskID, history) port.train(history, dataset) model:DataFrame = PModelDHondt(pDescr.getRecommendersIDs()) evalTool:AEvalTool = EvalToolDHondt({EvalToolDHondt.ARG_LEARNING_RATE_CLICKS: 0.03, EvalToolDHondt.ARG_LEARNING_RATE_VIEWS: 0.03 / 500}) return (taskID, port, model, evalTool, history)
def getContextFuzzyDHondtDirectOptimizeINF(): # taskID:str = "Web" + "ContextFuzzyDHondtDirectOptimizeINF" + "Roulette1" taskID:str = "Web" + "ContextFuzzyDHondtDirectOptimizeINF" + "Fixed" dataset:ADataset = DatasetST.readDatasets() # selector:ADHondtSelector = RouletteWheelSelector({RouletteWheelSelector.ARG_EXPONENT: 1}) selector:ADHondtSelector = TheMostVotedItemSelector({}) pToolOLin0802HLin1002:APenalization = PenalizationToolDefinition.exportProbPenaltyToolOLin0802HLin1002( InputSimulatorDefinition.numberOfAggrItems) rIDs, rDescs = InputRecomSTDefinition.exportPairOfRecomIdsAndRecomDescrs() history:AHistory = HistoryHierDF(taskID) # Init eTool evalTool:AEvalTool = EvalToolContext({ EvalToolContext.ARG_ITEMS: dataset.serialsDF, # ITEMS EvalToolContext.ARG_EVENTS: dataset.eventsDF, # EVENTS (FOR CALCULATING HISTORY OF USER) EvalToolContext.ARG_DATASET: "st", # WHAT DATASET ARE WE IN EvalToolContext.ARG_HISTORY: history}) # empty instance of AHistory is OK for ST dataset aDescDHont:AggregationDescription = InputAggrDefinition.exportADescDContextHondtDirectOptimizeINF(selector, pToolOLin0802HLin1002, evalTool) pDescr:Portfolio1AggrDescription = Portfolio1AggrDescription( taskID, rIDs, rDescs, aDescDHont) port:APortfolio = pDescr.exportPortfolio(taskID, history) port.train(history, dataset) model:DataFrame = PModelDHondt(pDescr.getRecommendersIDs()) return (taskID, port, model, evalTool, history)
def test21(): print("Simulation: ST FuzzyDHondtDirectOptimize") jobID: str = "Roulette1" selector = RouletteWheelSelector({RouletteWheelSelector.ARG_EXPONENT: 3}) pProbToolOLin0802HLin1002: APenalization = PenalizationToolDefinition.exportProbPenaltyToolOStat08HLin1002( InputSimulatorDefinition.numberOfAggrItems) rIDs, rDescs = InputRecomSTDefinition.exportPairOfRecomIdsAndRecomDescrs() pDescr: Portfolio1AggrDescription = Portfolio1AggrDescription( "FuzzyDHondtDirectOptimize" + jobID, rIDs, rDescs, InputAggrDefinition.exportADescDHondtDirectOptimizeThompsonSamplingINF( selector, pProbToolOLin0802HLin1002, "DCG")) batchID: str = "stDiv90Ulinear0109R1" dataset: DatasetST = DatasetST.readDatasets() behaviourFile: str = BehavioursST.getFile(BehavioursST.BHVR_LINEAR0109) behavioursDF: DataFrame = BehavioursST.readFromFileST(behaviourFile) model: DataFrame = PModelDHondtBanditsVotes(pDescr.getRecommendersIDs()) #lrClick:float = 0.03 #lrView:float = lrClick / 500 #eTool:AEvalTool = EvalToolDHondt({EvalToolDHondt.ARG_LEARNING_RATE_CLICKS: lrClick, # EvalToolDHondt.ARG_LEARNING_RATE_VIEWS: lrView}) eTool: AEvalTool = EvalToolDHondtBanditVotes({}) # simulation of portfolio simulator: Simulator = Simulator(batchID, SimulationST, argsSimulationDict, dataset, behavioursDF) simulator.simulate([pDescr], [model], [eTool], [HistoryHierDF(pDescr.getPortfolioID())])
def test02(): print("Test 02") rIDs, rDescr = InputRecomSTDefinition.exportPairOfRecomIdsAndRecomDescrs() model: DataFrame = PModelDHondt(rIDs) print(model) userID: int = 1 rItemIDsWithResponsibility: List[(int, Dict)] = [(1, { rIDs[0]: 0.05, rIDs[1]: 0.05, rIDs[2]: 0.05, rIDs[3]: 0.05, rIDs[4]: 0.05, rIDs[5]: 0.05, rIDs[6]: 0.05, rIDs[7]: 0.65 })] lrClick: float = 0.03 lrView: float = lrClick / 500 evalTool: AEvalTool = EvalToolDHondt({ EvalToolDHondt.ARG_LEARNING_RATE_CLICKS: lrClick, EvalToolDHondt.ARG_LEARNING_RATE_VIEWS: lrView }) evalTool.click(userID, rItemIDsWithResponsibility, 1, model, {}) for i in range(555): evalTool.displayed(userID, rItemIDsWithResponsibility, model, {}) print(model)
def test01(): print("Simulation: ML FuzzyDHondtDirectOptimize") jobID: str = "Roulette1" selector = RouletteWheelSelector({RouletteWheelSelector.ARG_EXPONENT: 1}) rIDs, rDescs = InputRecomSTDefinition.exportPairOfRecomIdsAndRecomDescrs() pDescr: Portfolio1AggrDescription = Portfolio1AggrDescription( "FuzzyDHondtDirectOptimize" + jobID, rIDs, rDescs, InputAggrDefinition.exportADescDHondtDirectOptimizeThompsonSampling( selector, "DCG")) batchID: str = "ml1mDiv90Ulinear0109R1" dataset: DatasetML = DatasetML.readDatasets() behaviourFile: str = BehavioursML.getFile(BehavioursML.BHVR_LINEAR0109) behavioursDF: DataFrame = BehavioursML.readFromFileMl1m(behaviourFile) #model:DataFrame = PModelDHont(pDescr.getRecommendersIDs()) model: DataFrame = PModelDHondtBanditsVotes(pDescr.getRecommendersIDs()) #lrClick:float = 0.03 #lrView:float = lrClick / 500 #eTool:AEvalTool = EvalToolDHondt({EvalToolDHondt.ARG_LEARNING_RATE_CLICKS: lrClick, # EvalToolDHondt.ARG_LEARNING_RATE_VIEWS: lrView}) eTool: AEvalTool = EvalToolDHondtBanditVotes({}) # simulation of portfolio simulator: Simulator = Simulator(batchID, SimulationML, argsSimulationDict, dataset, behavioursDF) simulator.simulate([pDescr], [model], [eTool], [HistoryHierDF(pDescr.getPortfolioID())])
def run(self, batchID: str, jobID: str): divisionDatasetPercentualSize: int uBehaviour: str repetition: int divisionDatasetPercentualSize, uBehaviour, repetition = \ InputABatchDefinition().getBatchParameters(self.datasetID)[batchID] # eTool:AEvalTool selector, eTool = self.getParameters()[jobID] rIDs, rDescs = InputRecomSTDefinition.exportPairOfRecomIdsAndRecomDescrs( ) aDescDHont: AggregationDescription = InputAggrDefinition.exportADescDHondt( selector) pDescr: Portfolio1AggrDescription = Portfolio1AggrDescription( self.getBatchName() + jobID, rIDs, rDescs, aDescDHont) model: DataFrame = PModelDHondtPersonalised( pDescr.getRecommendersIDs()) simulator: Simulator = InputSimulatorDefinition( ).exportSimulatorSlantour(batchID, divisionDatasetPercentualSize, uBehaviour, repetition) simulator.simulate([pDescr], [model], [eTool], [HistoryHierDF(pDescr.getPortfolioID())])
def run(self, batchID: str, jobID: str): divisionDatasetPercentualSize: int uBehaviour: str repetition: int divisionDatasetPercentualSize, uBehaviour, repetition = InputABatchDefinition( ).getBatchParameters(self.datasetID)[batchID] eTool: AEvalTool = EToolDoNothing({}) rIDs, rDescs = InputRecomSTDefinition.exportPairOfRecomIdsAndRecomDescrs( ) mainMethodID: str = "RecomW2Vtalli100000Ws1Vs32Upsmaxups1" # the best method for ST aDescRandomKfromN: AggregationDescription = InputAggrDefinition.exportADescRandomKfromN( mainMethodID) pDescr: Portfolio1AggrDescription = Portfolio1AggrDescription( self.getBatchName() + jobID, rIDs, rDescs, aDescRandomKfromN) model: DataFrame = DataFrame() simulator: Simulator = InputSimulatorDefinition( ).exportSimulatorSlantour(batchID, divisionDatasetPercentualSize, uBehaviour, repetition) simulator.simulate([pDescr], [model], [eTool], [HistoryHierDF(pDescr.getPortfolioID())])
def run(self, batchID: str, jobID: str): divisionDatasetPercentualSize: int uBehaviour: str repetition: int divisionDatasetPercentualSize, uBehaviour, repetition = InputABatchDefinition( ).getBatchParameters(self.datasetID)[batchID] selector, nImplFeedback = self.getParameters()[jobID] eTool: AEvalTool = EvalToolDHondtBanditVotes({}) rIDs, rDescs = InputRecomSTDefinition.exportPairOfRecomIdsAndRecomDescrs( ) aDescNegDHontThompsonSamplingI: AggregationDescription = InputAggrDefinition.exportADescDHondtThompsonSamplingINF( selector, nImplFeedback) pDescr: Portfolio1AggrDescription = Portfolio1AggrDescription( self.getBatchName() + jobID, rIDs, rDescs, aDescNegDHontThompsonSamplingI) model: DataFrame = PModelDHondtBanditsVotes( pDescr.getRecommendersIDs()) simulator: Simulator = InputSimulatorDefinition( ).exportSimulatorSlantour(batchID, divisionDatasetPercentualSize, uBehaviour, repetition) simulator.simulate([pDescr], [model], [eTool], [HistoryHierDF(pDescr.getPortfolioID())])
def getFuzzyDHontThompsonSamplingINF(): taskID:str = "Web" + "FuzzyDHondtThompsonSamplingINF" + "Fixed" + "OLin0802HLin1002" selector:ADHondtSelector = TheMostVotedItemSelector({}) penalization:APenalization = PenalizationToolDefinition.exportProbPenaltyToolOLin0802HLin1002(20) aDescDHont:AggregationDescription = InputAggrDefinition.exportADescDHondtThompsonSamplingINF(selector, penalization) rIDs, rDescs = InputRecomSTDefinition.exportPairOfRecomIdsAndRecomDescrs() pDescr:Portfolio1AggrDescription = Portfolio1AggrDescription( taskID, rIDs, rDescs, aDescDHont) history:AHistory = HistoryHierDF(taskID) dataset:ADataset = DatasetST.readDatasets() port:APortfolio = pDescr.exportPortfolio(taskID, history) port.train(history, dataset) model:DataFrame = PModelDHondtBanditsVotes(pDescr.getRecommendersIDs()) evalTool:AEvalTool = EvalToolDHondtBanditVotes({}) return (taskID, port, model, evalTool, history)
def test21(): print("Simulation: ST ContextDHondtINF") jobID: str = "Roulette1" selector = RouletteWheelSelector({RouletteWheelSelector.ARG_EXPONENT: 1}) #pProbToolOLin0802HLin1002:APenalization = PenalizationToolDefinition.exportProbPenaltyToolOStat08HLin1002( # InputSimulatorDefinition.numberOfAggrItems) pToolOLin0802HLin1002: APenalization = PenalizationToolDefinition.exportPenaltyToolOLin0802HLin1002( InputSimulatorDefinition.numberOfAggrItems) rIDs, rDescs = InputRecomSTDefinition.exportPairOfRecomIdsAndRecomDescrs() dataset: ADataset = DatasetST.readDatasets() events = dataset.eventsDF serials = dataset.serialsDF historyDF: AHistory = HistoryDF("test01") # Init evalTool evalTool: AEvalTool = EvalToolContext({ EvalToolContext.ARG_ITEMS: serials, # ITEMS EvalToolContext.ARG_EVENTS: events, # EVENTS (FOR CALCULATING HISTORY OF USER) EvalToolContext.ARG_DATASET: "st", # WHAT DATASET ARE WE IN EvalToolContext.ARG_HISTORY: historyDF }) # empty instance of AHistory is OK for ST dataset pDescr: Portfolio1AggrDescription = Portfolio1AggrDescription( "ContextDHondtNIF" + jobID, rIDs, rDescs, InputAggrDefinition.exportADescDContextHondtINF( selector, pToolOLin0802HLin1002, evalTool)) batchID: str = "stDiv90Ulinear0109R1" dataset: DatasetST = DatasetST.readDatasets() behaviourFile: str = BehavioursST.getFile(BehavioursST.BHVR_LINEAR0109) behavioursDF: DataFrame = BehavioursST.readFromFileST(behaviourFile) model: DataFrame = PModelDHondt(pDescr.getRecommendersIDs()) print(model) # simulation of portfolio simulator: Simulator = Simulator(batchID, SimulationST, argsSimulationDict, dataset, behavioursDF) simulator.simulate([pDescr], [model], [evalTool], [HistoryHierDF(pDescr.getPortfolioID())])
def run(self, batchID: str, jobID: str): divisionDatasetPercentualSize: int uBehaviour: str repetition: int divisionDatasetPercentualSize, uBehaviour, repetition = InputABatchDefinition( ).getBatchParameters(self.datasetID)[batchID] selector: ADHondtSelector selector, negativeImplFeedback = self.getParameters()[jobID] portfolioID: str = self.getBatchName() + jobID history: AHistory = HistoryHierDF(portfolioID) dataset: ADataset = DatasetST.readDatasets() events = dataset.eventsDF serials = dataset.serialsDF historyDF: AHistory = HistoryHierDF("test01") # Init evalTool evalTool: AEvalTool = EvalToolContext({ EvalToolContext.ARG_ITEMS: serials, # ITEMS EvalToolContext.ARG_EVENTS: events, # EVENTS (FOR CALCULATING HISTORY OF USER) EvalToolContext.ARG_DATASET: "st", # WHAT DATASET ARE WE IN EvalToolContext.ARG_HISTORY: historyDF }) # empty instance of AHistory is OK for ST dataset rIDs, rDescs = InputRecomSTDefinition.exportPairOfRecomIdsAndRecomDescrs( ) aDescContextDHont: AggregationDescription = InputAggrDefinition.exportADescDContextHondtINF( selector, negativeImplFeedback, evalTool) pDescr: Portfolio1AggrDescription = Portfolio1AggrDescription( portfolioID, rIDs, rDescs, aDescContextDHont) model: DataFrame = PModelDHondt(pDescr.getRecommendersIDs()) simulator: Simulator = InputSimulatorDefinition( ).exportSimulatorSlantour(batchID, divisionDatasetPercentualSize, uBehaviour, repetition) simulator.simulate([pDescr], [model], [evalTool], [history])
def test01(): print("Simulation: ML ContextDHondtINF") jobID: str = "Roulette1" selector = RouletteWheelSelector({RouletteWheelSelector.ARG_EXPONENT: 1}) #pProbToolOLin0802HLin1002:APenalization = PenalizationToolDefinition.exportProbPenaltyToolOStat08HLin1002( # InputSimulatorDefinition.numberOfAggrItems) pToolOLin0802HLin1002: APenalization = PenalizationToolDefinition.exportPenaltyToolOLin0802HLin1002( InputSimulatorDefinition.numberOfAggrItems) itemsDF: DataFrame = Items.readFromFileMl1m() usersDF: DataFrame = Users.readFromFileMl1m() historyDF: AHistory = HistoryDF("test01") eTool: AEvalTool = EvalToolContext({ EvalToolContext.ARG_USERS: usersDF, EvalToolContext.ARG_ITEMS: itemsDF, EvalToolContext.ARG_DATASET: "ml", EvalToolContext.ARG_HISTORY: historyDF }) rIDs, rDescs = InputRecomSTDefinition.exportPairOfRecomIdsAndRecomDescrs() pDescr: Portfolio1AggrDescription = Portfolio1AggrDescription( "ContextDHondtINF" + jobID, rIDs, rDescs, InputAggrDefinition.exportADescDContextHondtINF( selector, pToolOLin0802HLin1002, eTool)) batchID: str = "ml1mDiv90Ulinear0109R1" dataset: DatasetML = DatasetML.readDatasets() behaviourFile: str = BehavioursML.getFile(BehavioursML.BHVR_LINEAR0109) behavioursDF: DataFrame = BehavioursML.readFromFileMl1m(behaviourFile) model: DataFrame = PModelDHondt(pDescr.getRecommendersIDs()) # simulation of portfolio simulator: Simulator = Simulator(batchID, SimulationML, argsSimulationDict, dataset, behavioursDF) simulator.simulate([pDescr], [model], [eTool], [HistoryHierDF(pDescr.getPortfolioID())])
def getBanditTS(): taskID:str = "Web" + "BanditTS" + "Roulette1" selector = RouletteWheelSelector({RouletteWheelSelector.ARG_EXPONENT: 1}) rIDs, rDescs = InputRecomSTDefinition.exportPairOfRecomIdsAndRecomDescrs() pDescr:Portfolio1AggrDescription = Portfolio1AggrDescription( taskID, rIDs, rDescs, InputAggrDefinition.exportADescBanditTS(selector)) dataset:DatasetST = DatasetST.readDatasets() history:AHistory = HistoryHierDF(taskID) port:APortfolio = pDescr.exportPortfolio(taskID, history) port.train(history, dataset) model:DataFrame = PModelBandit(pDescr.getRecommendersIDs()) evalTool:AEvalTool = EvalToolBanditTS({}) return (taskID, port, model, evalTool, history)
def run(self, batchID:str, jobID:str): divisionDatasetPercentualSize:int uBehaviour:str repetition:int divisionDatasetPercentualSize, uBehaviour, repetition = InputABatchDefinition().getBatchParameters(self.datasetID)[batchID] eTool:AEvalTool = EToolDoNothing({}) rIDs, rDescs = InputRecomSTDefinition.exportPairOfRecomIdsAndRecomDescrs() aDescWeightedFAI:AggregationDescription = InputAggrDefinition.exportADescFAI() pDescr:Portfolio1AggrDescription = Portfolio1AggrDescription( "FAI" + jobID, rIDs, rDescs, aDescWeightedFAI) model:DataFrame = PModelDHondt(pDescr.getRecommendersIDs()) simulator:Simulator = InputSimulatorDefinition().exportSimulatorSlantour( batchID, divisionDatasetPercentualSize, uBehaviour, repetition) simulator.simulate([pDescr], [model], [eTool], [HistoryHierDF(pDescr.getPortfolioID())])
def test01(): print("Simulation: ML ContextFuzzyDHondtDirectOptimize") jobID: str = "Roulette1" selector: ADHondtSelector = RouletteWheelSelector( {RouletteWheelSelector.ARG_EXPONENT: 1}) itemsDF: DataFrame = Items.readFromFileMl1m() usersDF: DataFrame = Users.readFromFileMl1m() historyDF: AHistory = HistoryHierDF("test01") eTool: AEvalTool = EvalToolContext({ EvalToolContext.ARG_USERS: usersDF, EvalToolContext.ARG_ITEMS: itemsDF, EvalToolContext.ARG_DATASET: "ml", EvalToolContext.ARG_HISTORY: historyDF }) rIDs, rDescs = InputRecomSTDefinition.exportPairOfRecomIdsAndRecomDescrs() pDescr: Portfolio1AggrDescription = Portfolio1AggrDescription( "ContextFuzzyDHondtDirectOptimize" + jobID, rIDs, rDescs, InputAggrDefinition.exportADescContextFuzzyDHondtDirectOptimize( selector, eTool)) batchID: str = "ml1mDiv90Ulinear0109R1" dataset: DatasetML = DatasetML.readDatasets() behaviourFile: str = BehavioursML.getFile(BehavioursML.BHVR_LINEAR0109) behavioursDF: DataFrame = BehavioursML.readFromFileMl1m(behaviourFile) model: DataFrame = PModelDHondt(pDescr.getRecommendersIDs()) # simulation of portfolio simulator: Simulator = Simulator(batchID, SimulationML, argsSimulationDict, dataset, behavioursDF) simulator.simulate([pDescr], [model], [eTool], [historyDF])
def test01(): print("Simulation: ML FuzzyDHondtINF") jobID: str = "Roulette1" selector = RouletteWheelSelector({RouletteWheelSelector.ARG_EXPONENT: 1}) pProbToolOLin0802HLin1002: APenalization = PenalizationToolDefinition.exportProbPenaltyToolOStat08HLin1002( InputSimulatorDefinition.numberOfAggrItems) rIDs, rDescs = InputRecomSTDefinition.exportPairOfRecomIdsAndRecomDescrs() pDescr: Portfolio1AggrDescription = Portfolio1AggrDescription( "FuzzyDHondtINF" + jobID, rIDs, rDescs, InputAggrDefinition.exportADescDHondtINF(selector, pProbToolOLin0802HLin1002)) batchID: str = "ml1mDiv90Ulinear0109R1" dataset: DatasetML = DatasetML.readDatasets() behaviourFile: str = BehavioursML.getFile(BehavioursML.BHVR_LINEAR0109) behavioursDF: DataFrame = BehavioursML.readFromFileMl1m(behaviourFile) model: DataFrame = PModelDHondt(pDescr.getRecommendersIDs()) lrClick: float = 0.03 lrView: float = lrClick / 500 eTool: AEvalTool = EvalToolDHondt({ EvalToolDHondt.ARG_LEARNING_RATE_CLICKS: lrClick, EvalToolDHondt.ARG_LEARNING_RATE_VIEWS: lrView }) # simulation of portfolio simulator: Simulator = Simulator(batchID, SimulationML, argsSimulationDict, dataset, behavioursDF) simulator.simulate([pDescr], [model], [eTool], [HistoryHierDF(pDescr.getPortfolioID())])
def getParameters(self): rIDs, rDescr = InputRecomSTDefinition.exportPairOfRecomIdsAndRecomDescrs( ) rID1: str = "Recom" + "CosineCBcbdOHEupsmeanups1" + "MMR05" rID2: str = "Recom" + "CosineCBcbdOHEupsweightedMeanups5" + "MMR05" cosineCBMMR1: RecommenderDescription = InputRecomSTDefinition.exportRDescCosineCBcbdOHEupsmeanups1( ) cosineCBMMR1.getArguments()[ RecommenderCosineCB.ARG_USE_DIVERSITY] = True cosineCBMMR1.getArguments()[RecommenderCosineCB.ARG_MMR_LAMBDA] = 0.5 cosineCBMMR2: RecommenderDescription = InputRecomSTDefinition.exportRDescCosineCBcbdOHEupsweightedMeanups5( ) cosineCBMMR2.getArguments()[ RecommenderCosineCB.ARG_USE_DIVERSITY] = True cosineCBMMR2.getArguments()[RecommenderCosineCB.ARG_MMR_LAMBDA] = 0.5 aDict: Dict[str, object] = dict( zip(rIDs + [rID1, rID2], rDescr + [cosineCBMMR1, cosineCBMMR2])) return aDict
def test21(): print("Simulation: ST FuzzyDHondt") jobID: str = "Roulette1" selector = RouletteWheelSelector({RouletteWheelSelector.ARG_EXPONENT: 1}) rIDs, rDescs = InputRecomSTDefinition.exportPairOfRecomIdsAndRecomDescrs() pDescr: Portfolio1AggrDescription = Portfolio1AggrDescription( "FuzzyDHondt" + jobID, rIDs, rDescs, InputAggrDefinition.exportADescDHondt(selector)) batchID: str = "stDiv90Ulinear0109R1" dataset: DatasetST = DatasetST.readDatasets() behaviourFile: str = BehavioursST.getFile(BehavioursST.BHVR_LINEAR0109) behavioursDF: DataFrame = BehavioursST.readFromFileST(behaviourFile) model: DataFrame = PModelDHondt(pDescr.getRecommendersIDs()) print(model) lrClick: float = 0.1 lrView: float = lrClick / 300 evalTool: AEvalTool = EvalToolDHondt({ EvalToolDHondt.ARG_LEARNING_RATE_CLICKS: lrClick, EvalToolDHondt.ARG_LEARNING_RATE_VIEWS: lrView }) # simulation of portfolio simulator: Simulator = Simulator(batchID, SimulationST, argsSimulationDict, dataset, behavioursDF) simulator.simulate([pDescr], [model], [evalTool], [HistoryHierDF(pDescr.getPortfolioID())])