gsbdbi / bemb Goto Github PK
View Code? Open in Web Editor NEWLicense: MIT License
License: MIT License
The reshape_observable
method does not correctly recognize item-session-specific variables when named using the the prefix itemsession_
; the prefix price_
works.
The method does not recognize user-item-specific or user-item-session-specific observable names either.
Also allow for Y to be continuous in [0, 1]; in this case the optimization would be through loss minimization and not through variational inference. Note that we still want the sigmoid to be applied as the final head.
Link to notebook (use branch "mask-H-obs2prior")
This tutorial explains how to impose some structure on hierarchical priors. Specifically, it shows how to impose that some entries of the H and W matrix are fixed to 0 and shouldn't be learned. Here are some comments
Originally posted by @charlespebereau in gsbDBI/torch-choice#5 (comment)
_{uis}
and (ii) decompose the utility into a deterministic part and the error term: $\mathcal{U}{uis} = U{uis} + \varepsilon_{uis}$ .v1.0
.Corresponding branch: api-update
We are planning to refine and expand the current API of BEMBFlex
.
pred_item
and multiple class prediction.item_index[i]
). This only allows us to do binary classification . We might have to drop this feature.batch.label
or multi-class batch.item_index
. We plan to support arbitrary multi-class classifications.
pred_item=True
, the model will know the number of classes is exactly the num_items
parameter. Also, in this case, your ChoiceDataset
object does not need to have a label
attribute, since the model will look for the item_index
as the ground truth for training.pred_item=False
, now you need to supply a num_classes
to the BEMBFlex.__init__()
method. Also, you would need a label
attribute in the ChoiceDataset
object. The label
attribute should be a LongTensor
with values from {0, 1, ..., num_classes}
.predict_proba()
, the same name as inference methods of scikit-learn models.@torch.no_grad()
as a decorator, so you can use it however you want without being worried about gradient tracking.pred_items = True
, the batch
needs item_index
attribute only if it's involved in the utility computation (e.g., within-category computation).pred_items = False,
the batch
does not need to have a label
attribute.predict_proba()
is used as the following:batch = ChoiceDataset(...)
bemb = BEMBFlex(..., pred_item=True, ...)
proba = bemb.predict_proba(batch) # shape = (len(batch), num_items)
batch = ChoiceDataset(...)
# not that batch doesn't need to have a label attribute.
bemb = BEMBFlex(..., pred_item=False, num_classes=..., ...)
proba = bemb.predict_proba(batch) # shape = (len(batch), num_classes)
price
-variation is ambiguous, we propose to change it to sessionitem
-variation instead (this is precisely the definition of such variables).I am creating this issue on the behave of @kasince2k
Hi - it looks like in line 35 of bemb_flex_lightning.py file, there's a small typo (num_needs instead of num_seeds).
Refer to the link here for the file.
In this post I review the notebook on obs2prior. Note that I had reviewed the H_zero_mask option which is an extension to this notebook in the post above. Here are some comments
Originally posted by @charlespebereau in gsbDBI/torch-choice#5 (comment)
There is a lot of information on this page and I'm not sure what is the best way to present it - it depends on what the reader is looking for. I'll make some suggestions but will mostly highlight what information I didn't find or understand. Hopefully this will give you ideas and we can also discuss this at some point.
Response: I change it to a more general form by saying "the model predicts the probability for user
$u$ to purchase item$i$ as an increasing function of$U_{ui}$ . Our package support more general form of utility$U_{ui}$ than the inner product of two latent vectors.".
Response: I have added this to our documentation.
_{uis}
and (ii) decompose the utility into a deterministic part and the error term: $\mathcal{U}{uis} = U{uis} + \varepsilon_{uis}$ .Response: I have added substantive materials explaining the fourth possibility here.
Response: unless
obs2prior
is turned on, we set the distributions to have zero expectations.
Response: added.
Response: with
obs2prior
, the prior variance is whatever value imposed by theprior_variance
above. I made this more clear in the documentation by specifying that "prior_variance
term controls the variance of prior distribution andobs2prior
term controls the expectation of prior distribution."
Response: yes, we've added the support for
H_zero_mask
, which allows the user to force some entries of$H$ to be zeros. I have added a link to this tutorial to in the documentation.
Response: I have updated this by first writing down the
$P(i|u,s)$ withoutcategory_to_item
specified and then showed the user the possibility of normalizing across items in the same category only.
Originally posted by @charlespebereau in gsbDBI/torch-choice#5 (comment)
In this issue, we propose supporting additional distribution families (in addition to the current Gaussian family) as coefficient prior and posterior distributions. For example, using exponential distributions as the prior distribution of a coefficient adds support constraint to the coefficient (i.e., it should be non-negative).
What do you think? @kanodiaayush
This issue tracks using the simulated dataset to build BEMB demonstration.
I am reporting the issue identified by Rachel @rachelyangzhou please see below for the error message.
The package works with version 1.4.5
>>> import bemb
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/users/zhoury/.local/lib/python3.9/site-packages/bemb/__init__.py", line 2, in <module>
import bemb.model
File "/home/users/zhoury/.local/lib/python3.9/site-packages/bemb/model/__init__.py", line 2, in <module>
from .bemb_flex_lightning import *
File "/home/users/zhoury/.local/lib/python3.9/site-packages/bemb/model/bemb_flex_lightning.py", line 12, in <module>
import pytorch_lightning as pl
File "/home/users/zhoury/.local/lib/python3.9/site-packages/pytorch_lightning/__init__.py", line 34, in <module>
from pytorch_lightning.callbacks import Callback # noqa: E402
File "/home/users/zhoury/.local/lib/python3.9/site-packages/pytorch_lightning/callbacks/__init__.py", line 26, in <module>
from pytorch_lightning.callbacks.pruning import ModelPruning
File "/home/users/zhoury/.local/lib/python3.9/site-packages/pytorch_lightning/callbacks/pruning.py", line 30, in <module>
from pytorch_lightning.core.module import LightningModule
File "/home/users/zhoury/.local/lib/python3.9/site-packages/pytorch_lightning/core/__init__.py", line 15, in <module>
from pytorch_lightning.core.datamodule import LightningDataModule
File "/home/users/zhoury/.local/lib/python3.9/site-packages/pytorch_lightning/core/datamodule.py", line 21, in <module>
from pytorch_lightning.core.mixins import HyperparametersMixin
File "/home/users/zhoury/.local/lib/python3.9/site-packages/pytorch_lightning/core/mixins/__init__.py", line 15, in <module>
from pytorch_lightning.core.mixins.device_dtype_mixin import DeviceDtypeModuleMixin # noqa: F401
File "/home/users/zhoury/.local/lib/python3.9/site-packages/pytorch_lightning/core/mixins/device_dtype_mixin.py", line 19, in <module>
from typing_extensions import Self
ImportError: cannot import name 'Self' from 'typing_extensions' (/share/software/user/open/py-pytorch/1.8.1_py39/lib/python3.9/site-packages/typing_extensions.py)
There is also an issue with the latest torchmetric
version 0.9.3, rolling back to version 0.6.0
solves the issue.
Please see below for the error message.
>>> import bemb
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/users/zhoury/.local/lib/python3.9/site-packages/bemb/__init__.py", line 2, in <module>
import bemb.model
File "/home/users/zhoury/.local/lib/python3.9/site-packages/bemb/model/__init__.py", line 2, in <module>
from .bemb_flex_lightning import *
File "/home/users/zhoury/.local/lib/python3.9/site-packages/bemb/model/bemb_flex_lightning.py", line 12, in <module>
import pytorch_lightning as pl
File "/home/users/zhoury/.local/lib/python3.9/site-packages/pytorch_lightning/__init__.py", line 20, in <module>
from pytorch_lightning import metrics # noqa: E402
File "/home/users/zhoury/.local/lib/python3.9/site-packages/pytorch_lightning/metrics/__init__.py", line 15, in <module>
from pytorch_lightning.metrics.classification import ( # noqa: F401
File "/home/users/zhoury/.local/lib/python3.9/site-packages/pytorch_lightning/metrics/classification/__init__.py", line 14, in <module>
from pytorch_lightning.metrics.classification.accuracy import Accuracy # noqa: F401
File "/home/users/zhoury/.local/lib/python3.9/site-packages/pytorch_lightning/metrics/classification/accuracy.py", line 18, in <module>
from pytorch_lightning.metrics.utils import deprecated_metrics, void
File "/home/users/zhoury/.local/lib/python3.9/site-packages/pytorch_lightning/metrics/utils.py", line 22, in <module>
from torchmetrics.utilities.data import get_num_classes as _get_num_classes
ImportError: cannot import name 'get_num_classes' from 'torchmetrics.utilities.data' (/home/users/zhoury/.local/lib/python3.9/site-packages/torchmetrics/utilities/data.py)
We are planning on two improvements to the utility formula, changes were made to the utility parser helper function in the bemb.py
file.
Before we used price_obs
to denote (item, session)-specific observables; now we are allowing itemsession_obs
for a more intuitive utility formula. The updated utility parser allows these two ways simultaneously. For example, writing price_obs * beta_user
is the same as writing itemsession_obs * beta_user
in the utility_formula.
Coefficients with the same values for all users, items, and sessions are identified by the _constant suffix, now the parser parses all terms without reserved prefixes or suffixes to constant coefficients. This improvement makes the utility formula looks more aligned with the mathematical formulation of utility.
@charlespebereau @kanodiaayush
I have created a branch called formula-parser-update
and pull request here for this functionality.
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.