Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problems running the examples #129

Open
phiyodr opened this issue Jun 26, 2018 · 5 comments
Open

Problems running the examples #129

phiyodr opened this issue Jun 26, 2018 · 5 comments

Comments

@phiyodr
Copy link

phiyodr commented Jun 26, 2018

Hi,

cool project! I tried to run the examples but I run into errors.

I think that might be due to different package versions I use (mainly pandas and six). Would you be so kind and provide me with the version numbers you used back then.

Error in movielens_preprocess:

----> 1 movie = movie_preprocessing(movie)

<ipython-input-7-0d79f909437b> in movie_preprocessing(movie)
     21     tag_table = {token: idx for idx, token in enumerate(set(itertools.chain.from_iterable(movie_tag)))}
     22     movie_tag = pd.DataFrame(movie_tag)
---> 23     tag_table = pd.DataFrame(tag_table.items())

~/Environments/py3old/lib/python3.6/site-packages/pandas/core/frame.py in __init__(self, data, index, columns, dtype, copy)
    300                                          copy=False)
    301             else:
--> 302                 raise PandasError('DataFrame constructor not properly called!')
    303 
    304         NDFrame.__init__(self, mgr, fastpath=True)

PandasError: DataFrame constructor not properly called!

I could solve that replacing

tag_table = pd.DataFrame(tag_table.items())

with

tag_table=pd.DataFrame.from_dict(tag_table, orient='index')
tag_table.reset_index(level=0, inplace=True)

Error in movielens_bandit:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-9-263240bbee7e> in <module>()
----> 1 main()

<ipython-input-8-745ae3df14c6> in main()
    143     i = 0
    144     for bandit in experiment_bandit:
--> 145         policy = policy_generation(bandit, actions)
    146         seq_error = policy_evaluation(policy, bandit, streaming_batch_small, user_feature, reward_list,
    147                                       actions, action_context)

<ipython-input-8-745ae3df14c6> in policy_generation(bandit, actions)
     41 
     42     elif bandit == 'LinUCB':
---> 43         policy = linucb.LinUCB(actions, historystorage, modelstorage, 0.3, 20)
     44 
     45     elif bandit == 'LinThompSamp':

~/Environments/py3old/lib/python3.6/site-packages/striatum/bandit/linucb.py in __init__(self, history_storage, model_storage, action_storage, recommendation_cls, context_dimension, alpha)
     69             'theta': {},
     70         }
---> 71         for action_id in self._action_storage.iterids():
     72             self._init_action_model(model, action_id)
     73 

AttributeError: 'MemoryModelStorage' object has no attribute 'iterids'

Many thanks in advance!

@ianlini
Copy link
Collaborator

ianlini commented Jun 26, 2018

@taweihuang

@scheeloong
Copy link

Yea, it looks like their example code is heavily outdated. I just run the files under simulation instead. Those worked fine.

@scheeloong
Copy link

I managed to get the example to run, however, very hacky. feel free to pull from my forked version for temporary hacky fix.

@shiweixxx
Copy link

modify movielens_bandit.py:
1.policy = linucb.LinUCB(history_storage=historystorage, model_storage=modelstorage,action_storage=actions, alpha=0.3, context_dimension=18)
2.action[0]['action'].action_id as action[0].action.id

@xiwen426
Copy link

Just combine the previous two fix and get the example works. Feel free to pull from my forked.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants