Exemplo n.º 1
0
    def test_model_sampler(self):
        importance = 4.0
        N = 10000
        expected_ones = N * self._get_prob(importance)

        self._test_sampler(
            ModelSampler(self.dataset, UNWEIGHTED, MockModel(importance)), N,
            expected_ones)
Exemplo n.º 2
0
    def test_power_smoothing_sampler(self):
        importance = 4.0
        N = 10000
        expected_ones = N * self._get_prob(importance**0.5)

        self._test_sampler(
            PowerSmoothingSampler(
                ModelSampler(self.dataset, UNWEIGHTED, MockModel(importance))),
            N, expected_ones)
Exemplo n.º 3
0
    def test_adaptive_additive_smoothing_sampler(self):
        importance = 4.0
        c = (self.prior * 4.0 + (1.0 - self.prior) * 1.0) / 2.
        N = 10000
        expected_ones = N * self._get_prob(importance + c, 1.0 + c)

        self._test_sampler(
            AdaptiveAdditiveSmoothingSampler(
                ModelSampler(self.dataset, UNWEIGHTED, MockModel(importance))),
            N, expected_ones)
Exemplo n.º 4
0
    def test_additive_smoothing_sampler(self):
        importance = 4.0
        c = 2.0
        N = 10000
        expected_ones = N * self._get_prob(importance + c, 1.0 + c)

        self._test_sampler(
            AdditiveSmoothingSampler(ModelSampler(self.dataset, UNWEIGHTED,
                                                  MockModel(importance)),
                                     c=c), N, expected_ones)