How to use the contextualbandits.online._BasePolicy._add_choices function in contextualbandits

To help you get started, we’ve selected a few contextualbandits examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github david-cortes / contextualbandits / contextualbandits / online.py View on Github external
def _add_common_lin(self, alpha, nchoices, njobs):
        if isinstance(alpha, int):
            alpha = float(alpha)
        assert isinstance(alpha, float)

        _BasePolicy._add_choices(self, nchoices)
        _check_constructor_input(_ZeroPredictor(), nchoices)
        self.njobs = _check_njobs(njobs)
        self.alpha = alpha
        self.nchoices = nchoices
        self._oracles = [_LinUCBnTSSingle(self.alpha, self._ts) for n in range(nchoices)]
        if not self._ts:
            self.v_sq = self.alpha
            del self.alpha
        self.is_fitted = False