gsbDBI / torch-choice

Choice modeling with PyTorch: logit model and nested logit model
MIT License
39 stars 8 forks source link

31 change osbervable names itemsession obs name to sessionitem obs name #37

Closed TianyuDu closed 1 year ago

TianyuDu commented 1 year ago

The ChoiceDataset data structure uses keyword argument prefixes to determine the dependency of observable tensors, for example, the ChoiceDataset considers item_price as an item-specific observable tensor. For observable tensors depending on multiple dimensions (e.g., item-session-specific observable), the requirement on the prefix was strict in previous versions: itemsession_obs would work, but sessionitem_obs would not.

This patch implements a more flexible prefix system as the following:

  1. There is no change to the observable tensor depending on a single dimension, the item-specific tensor should start with item_, the user-specific tensor should start with user_, and the session-specific tensor should start with session_.
  2. For tensor depending on two dimensions, denoted x and y with x and y from ["item", "user", "session"], both prefixes xy_ and yx_ would work now. For example, the ChoiceDataset would consider tensors with prefix itemsession_ or sessionitem_ as (item, session)-specific variable.
  3. For tensor depending on all three of item, user, and session, there are six permutations of "item", "user", and "session", all six prefixes (itemsessionuser_, 'sessionitemuser_`, etc) would work.