david-cortes / contextualbandits

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

AssertionError for BayesianTS and BayesianUCB constructors #2

Closed erstrong closed 6 years ago

erstrong commented 6 years ago

The third argument for _check_constructor_input method is supposed to the batch_train boolean. The constructors for BayesianTS and BayesianUCB are instead passing a tuple.

AssertionError Traceback (most recent call last)
<ipython-input-117-96a94fb40784> in <module>()
      4 nchoices=50
      5 
----> 6 bayesian_ts=BayesianTS(nchoices)
      7 
      8 bayesian_ucb=BayesianUCB(nchoices)

~\AppData\Local\Continuum\anaconda3\lib\site-packages\contextualbandits\online.py in __init__(self, nchoices, method, beta_prior)
   1912     """
   1913     def __init__(self, nchoices, method='advi', beta_prior=((1,1),3)):
-> 1914         _check_constructor_input(_BetaPredictor(1,1),nchoices,((1,1),2))
   1915         self.beta_prior = beta_prior
   1916         self.nchoices = nchoices

~\AppData\Local\Continuum\anaconda3\lib\site-packages\contextualbandits\utils.py in _check_constructor_input(base_algorithm, nchoices, batch_train)
     54     assert ('fit' in dir(base_algorithm)) and ('predict' in dir(base_algorithm))
     55     if batch_train:
---> 56         assert 'partial_fit' in dir(base_algorithm)
     57     return None
     58 
david-cortes commented 6 years ago

Sorry about that and thanks again for reporting the bug! Fixes pushed to github and a fixed version pushed to pypi.

erstrong commented 6 years ago

Thanks!