Closed Shriaachar closed 1 year ago
Could you be more specific?
After applying online policy's we are not able to get the topN products . its throws an error.
I'm unable to find any issue. The following code for example works for me:
import numpy as np
from sklearn.linear_model import LogisticRegression
from contextualbandits.online import EpsilonGreedy
rng = np.random.default_rng(seed=123)
nrows = 100
ncols = 10
narms = 5
X = rng.standard_normal(size=(nrows,ncols))
a = rng.integers(narms, size=nrows)
r = (rng.random(size=nrows) <= .3).astype(int)
policy = EpsilonGreedy(
LogisticRegression(),
narms
)
policy.fit(X,a,r)
policy.topN(X, n=3)
Are you able to provide a reproducible example with random data resulting in some error being thrown?
AttributeError Traceback (most recent call last) Input In [1], in <cell line: 18>() 13 policy = EpsilonGreedy( 14 LogisticRegression(), 15 narms 16 ) 17 policy.fit(X,a,r) ---> 18 policy.topN(X, n=3)
AttributeError: 'EpsilonGreedy' object has no attribute 'topN'
I am getting this error
I am guessing that you are using an older version of this package that didn't support such functionality. Try updating:
pip install -U contextualbandits
Getting requirements to build wheel: started Getting requirements to build wheel: finished with status 'done' Preparing wheel metadata: started Preparing wheel metadata: finished with status 'done' Requirement already satisfied: joblib>=0.13 in c:\users\shridhar.s\anaconda3\lib\site-packages (from contextualbandits) (1.1.0) Requirement already satisfied: scipy in c:\users\shridhar.s\anaconda3\lib\site-packages (from contextualbandits) (1.7.3) Requirement already satisfied: numpy>=1.17 in c:\users\shridhar.s\anaconda3\lib\site-packages (from contextualbandits) (1.21.5) Requirement already satisfied: scikit-learn>=0.22 in c:\users\shridhar.s\anaconda3\lib\site-packages (from contextualbandits) (1.1.3) Requirement already satisfied: pandas>=0.25.0 in c:\users\shridhar.s\anaconda3\lib\site-packages (from contextualbandits) (1.4.2) Requirement already satisfied: cython in c:\users\shridhar.s\anaconda3\lib\site-packages (from contextualbandits) (0.29.28) Requirement already satisfied: pytz>=2020.1 in c:\users\shridhar.s\anaconda3\lib\site-packages (from pandas>=0.25.0->contextualbandits) (2021.3) Requirement already satisfied: python-dateutil>=2.8.1 in c:\users\shridhar.s\anaconda3\lib\site-packages (from pandas>=0.25.0->contextualbandits) (2.8.2) Requirement already satisfied: six>=1.5 in c:\users\shridhar.s\anaconda3\lib\site-packages (from python-dateutil>=2.8.1->pandas>=0.25.0->contextualbandits) (1.16.0) Requirement already satisfied: threadpoolctl>=2.0.0 in c:\users\shridhar.s\anaconda3\lib\site-packages (from scikit-learn>=0.22->contextualbandits) (2.2.0) Building wheels for collected packages: contextualbandits Building wheel for contextualbandits (PEP 517): started Building wheel for contextualbandits (PEP 517): finished with status 'error' Failed to build contextualbandits
See it's failed to build contextualbandits
So it's a version problem then. The installation error trace unfortunately doesn't show what the exact error is, so I cannot help with that.
Perhaps adding argument --verbose
or something like that could help in showing an error trace, but I'm no expert on pip
. There's also the possibility of using python setup.py install
if you download the repository, which might provide some hint of what is failing.
Hi David Every time I ran the topN I am getting different recommendations.
How can we resolve this ?
As it should be. You can check the docs and references for more info.
topN arms for all online policy's not available. Results obtained cannot be mapped with requirements