GithubHelp home page GithubHelp logo

fidelity / mab2rec Goto Github PK

View Code? Open in Web Editor NEW
99.0 12.0 20.0 3.58 MB

[AAAI 2024] Mab2Rec: Multi-Armed Bandits Recommender

Home Page: https://fidelity.github.io/mab2rec/

Python 20.60% Jupyter Notebook 78.27% Shell 0.97% Makefile 0.07% Batchfile 0.09%
multi-armed-bandits recommendation recsys

mab2rec's People

Contributors

bkleyn avatar brianwarner avatar dorukkilitcioglu avatar fberlinger avatar j-svensmark avatar nagireddyakshay avatar saraekmansvt avatar skadio avatar takojunior avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mab2rec's Issues

response values

in the user item interaction data.. can the response be a real number or integer and not just binary 0 or 1?

Is it possible to have time_of_day and day_of_week as context features?

Hi, we would like to train a model that adjusts recommendations to a set of user preference features as well as time related features, specifically time of day and day of week. Is that possible to do with mab2rec and if so how? The API seems to be designed to take user features and/or item features.

```error in evaluation

 File "C:\Users\ayush\AppData\Local\Temp\2\ipykernel_5524\2998262892.py", line 13, in <module>
    response_col = 'response')

  File "C:\ProgramData\Anaconda3\envs\test_env\lib\site-packages\mab2rec\pipeline.py", line 417, in benchmark
    return _bench(**args)

  File "C:\ProgramData\Anaconda3\envs\test_env\lib\site-packages\mab2rec\pipeline.py", line 526, in _bench
    save_file=None)

  File "C:\ProgramData\Anaconda3\envs\test_env\lib\site-packages\mab2rec\pipeline.py", line 286, in score
    recs_of_batch, scores_of_batch = recommender.recommend(contexts, excluded_arms_batch, return_scores=True)

  File "C:\ProgramData\Anaconda3\envs\test_env\lib\site-packages\mab2rec\rec.py", line 323, in recommend
    expectations = self.mab.predict_expectations(contexts)

  File "C:\ProgramData\Anaconda3\envs\test_env\lib\site-packages\mabwiser\mab.py", line 1229, in predict_expectations
    return self._imp.predict_expectations(contexts)

  File "C:\ProgramData\Anaconda3\envs\test_env\lib\site-packages\mabwiser\linear.py", line 151, in predict_expectations
    return self._parallel_predict(contexts, is_predict=False)

  File "C:\ProgramData\Anaconda3\envs\test_env\lib\site-packages\mabwiser\base_mab.py", line 227, in _parallel_predict
    for i in range(n_jobs))

  File "C:\ProgramData\Anaconda3\envs\test_env\lib\site-packages\joblib\parallel.py", line 1043, in __call__
    if self.dispatch_one_batch(iterator):

  File "C:\ProgramData\Anaconda3\envs\test_env\lib\site-packages\joblib\parallel.py", line 861, in dispatch_one_batch
    self._dispatch(tasks)

  File "C:\ProgramData\Anaconda3\envs\test_env\lib\site-packages\joblib\parallel.py", line 779, in _dispatch
    job = self._backend.apply_async(batch, callback=cb)

  File "C:\ProgramData\Anaconda3\envs\test_env\lib\site-packages\joblib\_parallel_backends.py", line 208, in apply_async
    result = ImmediateResult(func)

  File "C:\ProgramData\Anaconda3\envs\test_env\lib\site-packages\joblib\_parallel_backends.py", line 572, in __init__
    self.results = batch()

  File "C:\ProgramData\Anaconda3\envs\test_env\lib\site-packages\joblib\parallel.py", line 263, in __call__
    for func, args, kwargs in self.items]

  File "C:\ProgramData\Anaconda3\envs\test_env\lib\site-packages\joblib\parallel.py", line 263, in <listcomp>
    for func, args, kwargs in self.items]

  File "C:\ProgramData\Anaconda3\envs\test_env\lib\site-packages\mabwiser\linear.py", line 212, in _predict_contexts
    arm_to_expectation[arm] = arm_to_model[arm].predict(row)

  File "C:\ProgramData\Anaconda3\envs\test_env\lib\site-packages\mabwiser\linear.py", line 93, in predict
    beta_sampled = self.rng.multivariate_normal(self.beta, np.square(self.alpha) * self.A_inv)

  File "C:\ProgramData\Anaconda3\envs\test_env\lib\site-packages\mabwiser\utils.py", line 258, in multivariate_normal
    return np.squeeze(self.rng.multivariate_normal(mean, covariance, size=size, method='cholesky'))

  File "_generator.pyx", line 3625, in numpy.random._generator.Generator.multivariate_normal

  File "<__array_function__ internals>", line 6, in cholesky

  File "C:\ProgramData\Anaconda3\envs\test_env\lib\site-packages\numpy\linalg\linalg.py", line 763, in cholesky
    r = gufunc(a, signature=signature, extobj=extobj)

  File "C:\ProgramData\Anaconda3\envs\test_env\lib\site-packages\numpy\linalg\linalg.py", line 91, in _raise_linalgerror_nonposdef
    raise LinAlgError("Matrix is not positive definite")

LinAlgError: Matrix is not positive definite

Still getting error after binarizing....

Originally posted by @ayush488 in #14 (comment)

user_id not in data file.

Not able to understand why I am getting a ValueError: user_id not in data file
this is my statement:

reco_to_results, reco_to_metrics = benchmark(recommenders, 
                                             metrics=metrics,
                                             train_data=X_train, 
                                             test_data=X_test,
                                             user_features=df_users_X, 
                                             user_id_col= 'ID',
                                               item_id_col= 'MailerID',
                                               response_col = 'sales_net')   

Small Dataset issue

Which agent would be the best to use if i've a dataset of around 3000 unique user_id with 27 items? Tried with LinGreedy, LinUCB not able to get scores of all users with them. It's return NaN in scores.

Error in training

I am getting the following error while training;

SystemError: <built-in function _abc_instancecheck> returned a result with an error set

my input as follows:

rec = BanditRecommender(LearningPolicy.LinGreedy(epsilon=0.1), top_k=4)

# Train on (user, item, response) interactions in train data using user features 
train(rec, data=X_train, 
      user_features=df_users,
      item_features=df_mailers,
      user_id_col= 'ID',
      item_id_col= 'MailerID',
      response_col = 'sales_net'
      )

all user and mailer feature are categorical (not one hot encoded)

What could be the reason?

regret metrics

Hi Team, Thanks for sharing this wonderful library. can you guide me on how to use regret metrics while using MAB?

Errors for "NoReturn" type

The NoReturn type is used in these places:

"NoReturn" is meant to be used to end further processing, for example when calling exit(). The functions above returns nothing (explicitly) but are not meant to end the program, which results in editor warnings about code after this being unreachable. What you might want to use instead is the None type, i.e.: func() -> None instead of func() -> NoReturn

user and item features

what are the data types supported in the user and item features?
Numeric or everything has to be one hot encoded?

Recommendation when passing a reward score that will be greater than 33

Hi,

I was trying to pass a reward(response column) score that was continuous and will be higher in the 1000s. The recommend function limits the expectations to a sigmoid function before selecting top N arms. This is creating issues in validation as well as scoring because if the reward was higher than 33, all the arms will have expectation as 1. Hence the top N arms selected are not exactly the real top N arms. Can we pass the sigmoid transformation as an optional parameter which can be bypassed? Is there any other option to use a reward score and get the expected reward itself? With predict_expectations I am getting the right reward scale, but this sigmoid transformation is tagging everything to 1 later.

'''
Take sigmoid of expectations so that values are between 0 and 1
expectations = expit(pd.DataFrame(expectations)[self.mab.arms].values)
'''

Thanks,
David

Excluded items aren't replaced for top-k recommendations

When the item_eligibility parameter is used to control the recommendations for customers while a top-k is specified, the score pipeline returns less than top-k items if one of the items that would've been recommended to the user is excluded.

Example:

k = 4
items = [1, 2, 3, 4, 5]
scores = [0.9, 0.8, 0.7, 0.6, 0.5]
exclusion_list = [1]
recs = [2, 3, 4, 5] or [2, 3, 4]?

M2R returns [2, 3, 4], whereas it can backfill from non-excluded items and return [2, 3, 4, 5].

Originally reported by @nateewall, you can add more to the issue if there's any other issues you've seen with this behavior.

Using GPU for training (BanditRecommender)

Hi there,

Just want to check whether this package supports GPU training where I can put the BanditRecommender model into GPU to train along with the dataset?

Cheers!

Ranking using MAB

Hi Team, Thanks for creating this library. Can you guide me on how to use this library for ranking?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.