david-cortes / contextualbandits

Python implementations of contextual bandits algorithms
http://contextual-bandits.readthedocs.io
BSD 2-Clause "Simplified" License
749 stars 146 forks source link

_BasePolicy.add_arm(); NameError: name 'base_algorithm' is not defined #61

Closed Groogg closed 1 year ago

Groogg commented 1 year ago

When using BootstrappedUCB.add_arm() the NameError: name 'base_algorithm' is not defined is raised on line 297 under the _BasePolicy.add_arm() method.

fitted_classifier = self._make_bootstrapped(base_algorithm, self._percentile, 
                                            self._ts_byrow, self._ts_weighted)

When looking at the code, the base_algorithm is not part of the function signature but is referred to as self. base_algorithm at line 300.

 if isinstance(self.base_algorithm, list):
            if (fitted_classifier is not None):
                raise ValueError("Must pass 'fitted_classifier' when using different 'base_algorithm' per arm.")

To be corrected.

david-cortes commented 1 year ago

Thanks for the bug report. Should be fixed now.