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 = InputRecomRRDefinition.exportPairOfRecomIdsAndRecomDescrs( ) p1AggrDescr: Portfolio1AggrDescription = Portfolio1AggrDescription( "FDHont" + jobID, rIDs, rDescs, InputAggrDefinition.exportADescDHondt(selector)) recommenderID: str = "TheMostPopular" rDescr: RecommenderDescription = RecommenderDescription( RecommenderTheMostPopular, {}) pDescr: APortfolioDescription = PortfolioDynamicDescription( "Dynamic" + "FDHontPersStat" + jobID, recommenderID, rDescr, "FDHondt", p1AggrDescr) model: DataFrame = PModelDHondtPersonalisedStat( p1AggrDescr.getRecommendersIDs()) simulator: Simulator = InputSimulatorDefinition( ).exportSimulatorRetailRocket(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 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 selector, eTool = self.getParameters()[jobID] rIDs, rDescs = InputRecomMLDefinition.exportPairOfRecomIdsAndRecomDescrs( ) aDescDHont: AggregationDescription = InputAggrDefinition.exportADescDHondt( selector) pDescr: Portfolio1AggrDescription = Portfolio1AggrDescription( self.getBatchName() + jobID, rIDs, rDescs, aDescDHont) rIds: List[str] = pDescr.getRecommendersIDs() model: DataFrame = PModelHybrid( PModelDHondt(rIds), PModelDHondtPersonalisedStat(rIds), { PModelHybrid.ARG_MODE_SKIP: True, PModelHybrid.ARG_SKIP_CLICK_THRESHOLD: 3 }) simulator: Simulator = InputSimulatorDefinition().exportSimulatorML1M( batchID, divisionDatasetPercentualSize, uBehaviour, repetition) simulator.simulate([pDescr], [model], [eTool], [HistoryHierDF(pDescr.getPortfolioID())])
def getFuzzyDHont(): #taskID:str = "Web" + "FuzzyDHondt" + "Roulette1" taskID:str = "Web" + "FuzzyDHondt" + "Fixed" dataset:ADataset = DatasetST.readDatasets() #selector:ADHondtSelector = RouletteWheelSelector({RouletteWheelSelector.ARG_EXPONENT: 1}) selector:ADHondtSelector = TheMostVotedItemSelector({}) aDescDHont:AggregationDescription = InputAggrDefinition.exportADescDHondt(selector) 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 run(self, batchID: str, jobID: str): divisionDatasetPercentualSize: int uBehaviour: str repetition: int divisionDatasetPercentualSize, uBehaviour, repetition = InputABatchDefinition( ).getBatchParameters(self.datasetID)[batchID] portfolioID: str = self.getBatchName() + jobID history: AHistory = HistoryHierDF(portfolioID) #eTool:AEvalTool selector, eTool = self.getParameters()[jobID] rIDs, rDescs = InputRecomMLDefinition.exportPairOfRecomIdsAndRecomDescrsCluster( ) aDescDHont: AggregationDescription = InputAggrDefinition.exportADescDHondt( selector) pDescr: Portfolio1AggrDescription = Portfolio1AggrDescription( self.getBatchName() + jobID, rIDs, rDescs, aDescDHont) print(pDescr.getRecommendersIDs()) model: DataFrame = PModelDHondtPersonalised( pDescr.getRecommendersIDs()) inputSimulatorDefinition = InputSimulatorDefinition() inputSimulatorDefinition.numberOfAggrItems = 100 simulator: Simulator = inputSimulatorDefinition.exportSimulatorML1M( batchID, divisionDatasetPercentualSize, uBehaviour, repetition) simulator.simulate([pDescr], [model], [eTool], [history])
def test01(): print("Simulation: ML 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 = "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 test01(): print("Simulation: RR Dynamic") lrClick: float = 0.03 #lrView:float = lrClick / 300 lrViewDivisor: float = 250 jobID: str = "Fixed" + "Clk" + str(lrClick).replace( ".", "") + "ViewDivisor" + str(lrViewDivisor).replace(".", "") selector: ADHondtSelector = TheMostVotedItemSelector({}) rIDs, rDescs = InputRecomRRDefinition.exportPairOfRecomIdsAndRecomDescrs() p1AggrDescr: Portfolio1AggrDescription = Portfolio1AggrDescription( "FDHont" + jobID, rIDs, rDescs, InputAggrDefinition.exportADescDHondt(selector)) recommenderID: str = "TheMostPopular" rDescr: RecommenderDescription = RecommenderDescription( RecommenderTheMostPopular, {}) pDescr: APortfolioDescription = PortfolioDynamicDescription( "Dynamic" + "FDHontPersStat" + jobID, recommenderID, rDescr, "FDHondt", p1AggrDescr) batchID: str = "rrDiv90Ulinear0109R1" dataset: DatasetRetailRocket = DatasetRetailRocket.readDatasetsWithFilter( minEventCount=50) behaviourFile: str = BehavioursRR.getFile(BehavioursRR.BHVR_LINEAR0109) behavioursDF: DataFrame = BehavioursRR.readFromFileRR(behaviourFile) model: DataFrame = PModelDHondtPersonalisedStat( p1AggrDescr.getRecommendersIDs()) eTool: AEvalTool = EvalToolDHondtPersonal({ EvalToolDHondt.ARG_LEARNING_RATE_CLICKS: lrClick, EvalToolDHondt.ARG_LEARNING_RATE_VIEWS: lrClick / lrViewDivisor }) # simulation of portfolio simulator: Simulator = Simulator(batchID, SimulationRR, argsSimulationDict, dataset, behavioursDF) simulator.simulate([pDescr], [model], [eTool], [HistoryHierDF(pDescr.getPortfolioID())])