75dff38e70ec291fbd60382174277fcadddfd285,reagent/ope/estimators/contextual_bandits_estimators.py,DMEstimator,evaluate,#DMEstimator#Any#,82

Before Change



    def evaluate(self, input: BanditsEstimatorInput, **kwargs) -> EstimatorResults:
        self.reset()
        for log in input.logs:
            log_reward = RunningAverage()
            tgt_reward = RunningAverage()
            gt_reward = RunningAverage()
            for sample in log.samples:
                log_reward.add(sample.logged_reward)
                rewards = input.target_model(sample.context)
                tgt_reward.add(rewards[sample.target_action])
                rewards = input.ground_truth_model(sample.context)
                gt_reward.add(rewards[sample.target_action])
            self._append_estimate(
                log_reward.average, tgt_reward.average, gt_reward.average
            )
        return self.results


class IPSEstimator(Estimator):

After Change


        if not self._train_model(input.samples, 0.8, logger):
            return None
        log_avg = RunningAverage()
        tgt_avg = RunningAverage()
        gt_avg = RunningAverage()
        for sample in input.samples:
            log_avg.add(sample.log_reward)
            _, tgt_reward = self._calc_dm_reward(input.action_space, sample)
            tgt_avg.add(tgt_reward)
            gt_avg.add(sample.ground_truth_reward)
        return EstimatorResult(
            log_avg.average, tgt_avg.average, gt_avg.average, tgt_avg.count
        )

    def __repr__(self):
        return f"DMEstimator(trainer({self._trainer.name},device({self._device}))"
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 22

Instances


Project Name: facebookresearch/Horizon
Commit Name: 75dff38e70ec291fbd60382174277fcadddfd285
Time: 2020-06-10
Author: jialiu@fb.com
File Name: reagent/ope/estimators/contextual_bandits_estimators.py
Class Name: DMEstimator
Method Name: evaluate


Project Name: facebookresearch/Horizon
Commit Name: 75dff38e70ec291fbd60382174277fcadddfd285
Time: 2020-06-10
Author: jialiu@fb.com
File Name: reagent/ope/estimators/contextual_bandits_estimators.py
Class Name: DoublyRobustEstimator
Method Name: evaluate


Project Name: facebookresearch/Horizon
Commit Name: 75dff38e70ec291fbd60382174277fcadddfd285
Time: 2020-06-10
Author: jialiu@fb.com
File Name: reagent/ope/estimators/contextual_bandits_estimators.py
Class Name: IPSEstimator
Method Name: evaluate