fidelity / mab2rec Goto Github PK
View Code? Open in Web Editor NEW[AAAI 2024] Mab2Rec: Multi-Armed Bandits Recommender
Home Page: https://fidelity.github.io/mab2rec/
[AAAI 2024] Mab2Rec: Multi-Armed Bandits Recommender
Home Page: https://fidelity.github.io/mab2rec/
in the user item interaction data.. can the response be a real number or integer and not just binary 0 or 1?
How can we implement contextual volatile MABs?
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.
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)
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')
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.
Once the bandit is trained with all the arms/actions- context- reward triplets, is it possible to constrain the recommendations/ scoring for each person to a few arms/actions?
Please review this one.. By mistake I created it in mabwiser.. But it is related to mab2rec.
fidelity/mabwiser#59
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?
Can the user and item feature contain a mixture of continuous and categorical features?
What could be the reason that LinUCB is returning NaN in the predicted rewards?
LinGreedy is working fine with the same data.
Hi Team, Thanks for sharing this wonderful library. can you guide me on how to use regret metrics while using MAB?
Can you please explain where have you used the item_features? I don't seem to find it being used anywhere except for loading.
User and item properties may change over time.
How should I prepare the dataframe while giving it to the model?
Because the userid will still be the same
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
what are the data types supported in the user and item features?
Numeric or everything has to be one hot encoded?
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
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.
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!
Is it possible to get the estimated reward for a user_id and item_id from any of the bandits?
Hi Team, Thanks for creating this library. Can you guide me on how to use this library for ranking?
When calling the recommend function with a single context I get the following error (ValueError: If using all scalar values, you must pass an index).
It works fine to get recommendations for two or more contexts.
This notebook has a minimal example of the problem: https://colab.research.google.com/drive/1gubWTFNaQ1m6vhQ_fGlydo0_2I6WnJTI?usp=sharing
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.