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

Basket models #216

Open
wants to merge 62 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
311a423
ADD: Trip, TripDataset and Shopper
julesdesir Jan 15, 2025
7b6fc4b
MAINT: fix typos in docstrings
julesdesir Jan 15, 2025
834757b
ADD: data preprocessing for basket models
julesdesir Jan 15, 2025
1560348
MAINT: fix typos in docstrings
julesdesir Jan 15, 2025
bf71ef5
ENH: remove unnecessary enumerate() in for loop
julesdesir Jan 15, 2025
1909362
MAINT: fix typos in docstrings and variable names
julesdesir Jan 15, 2025
2ca140c
FIX: weight of the loss of the last batch in the loss of the whole epoch
julesdesir Jan 15, 2025
235f7d7
TST: tests for basket models
julesdesir Jan 15, 2025
f7e06de
DOC: add SHOPPER in readme and in docs
julesdesir Jan 15, 2025
aa000ab
DOC: fix typos in readme
julesdesir Jan 15, 2025
23c426a
DOC: add SHOPPER references in documentation index
julesdesir Jan 16, 2025
dc6347b
FIX: path to data for basket models
julesdesir Jan 17, 2025
0581efe
ENH: first part of changes following review
julesdesir Jan 17, 2025
7d75651
ENH: use 5 variables for batch instead of only 1
julesdesir Jan 17, 2025
1613925
ENH: second part of changes following review
julesdesir Jan 17, 2025
7171cbe
ENH: lazy instantiation in .fit + some attributes moved to __init__
julesdesir Jan 20, 2025
380333b
TST: update Shopper tests with the new attributes in __init__
julesdesir Jan 20, 2025
e0b266a
ENH: add assortment attribute to Trip and take into account assortmen…
julesdesir Jan 21, 2025
92a07e4
TST: update Shopper tests with assortment handling
julesdesir Jan 21, 2025
0dd49dc
FIX: handling assortments when stage=3
julesdesir Jan 21, 2025
76281d9
MAINT: rename base_basket.py
julesdesir Jan 21, 2025
bd41337
MAINT: clean useless comment lines
julesdesir Jan 21, 2025
354e925
ENH: first part of changes following 2nd review round
julesdesir Jan 22, 2025
9fc78f0
ENH: second part of changes following 2nd review round
julesdesir Jan 22, 2025
094c133
ADD: __getitem__ method for the TripDataset class
julesdesir Jan 22, 2025
8743f65
DEP: np.in1d deprecated since NumPy 2.0, use np.isin instead
julesdesir Jan 22, 2025
25aee29
MAINT: fix typos
julesdesir Jan 22, 2025
1dd39b1
ENH: move thinking ahead to a dedicated function
julesdesir Jan 23, 2025
22aa356
ENH: remove unnecessary case distinction when computing item_utilities
julesdesir Jan 23, 2025
45982a2
FIX: load_model without losing hyperparameter values
julesdesir Jan 23, 2025
7a5b4fb
ENH: a call to from_csv builds only one TripDataset and not train/val…
julesdesir Jan 24, 2025
6d45812
MAINT: move sys.path.append(../)
julesdesir Feb 7, 2025
4dd3afa
ADD: few basic tests
VincentAuriau Feb 9, 2025
e567f03
ENH: all changes made on separate repo
julesdesir Feb 10, 2025
6125441
ADD: Shopper tutorial notebook
julesdesir Feb 10, 2025
5ed9bef
ENH: epsilon in log computation during .evaluate
julesdesir Feb 10, 2025
9291a85
TST: update tesrs with last changes
julesdesir Feb 10, 2025
8257a90
TST: small fix
julesdesir Feb 10, 2025
8709dff
MAINT: fix url for 'Open In Colab' in Shopper tutorial notebook
julesdesir Feb 10, 2025
cae851d
Simplify example notebook
VincentAuriau Feb 10, 2025
4c9092d
ADD: val_dataset in fit
VincentAuriau Feb 10, 2025
5a3fcb3
ADD: few basic tests
VincentAuriau Feb 10, 2025
ae33742
ADD: default arguments
VincentAuriau Feb 10, 2025
cce836a
FIX: tests
VincentAuriau Feb 11, 2025
ba9052f
ADD: default values for week & customer if not defined
VincentAuriau Feb 11, 2025
6dc73a7
ADD: updated notebook
VincentAuriau Feb 11, 2025
fc48214
ENH: small changes after review
julesdesir Feb 11, 2025
87ea490
DOC: add Shopper tutorial notebook to the readme
julesdesir Feb 11, 2025
ab02786
Merge pull request #220 from artefactory/few-changes
julesdesir Feb 11, 2025
0096d0f
ADD: __init__
VincentAuriau Feb 11, 2025
f515b1c
small modif
VincentAuriau Feb 11, 2025
560834e
FIX: add Trip class to init file
julesdesir Feb 12, 2025
3d7622b
MAINT: rename item_popularity to item_intercept
julesdesir Feb 12, 2025
948dad1
MAINT: rename compute_unordered_basket_likelihood to compute_basket_l…
julesdesir Feb 12, 2025
e9eb95c
MAINT: rename assortments to available_items (attribute of TripDatase…
julesdesir Feb 12, 2025
00337bc
MAINT: change from 'customer' to 'store'
julesdesir Feb 12, 2025
37d4390
ENH: remove 'id' attribute from Trip class
julesdesir Feb 12, 2025
c86b000
TST: small fix
julesdesir Feb 12, 2025
d5fe536
ADD: possibility to call some functions directly with a Trip object
julesdesir Feb 12, 2025
e1e7e50
ADD: __str__ method for the Trip class
julesdesir Feb 13, 2025
2040e8b
ENH: enhancements of illustrative notebooks for basket models
julesdesir Feb 13, 2025
d4895cf
TST: update test_dataset.py with last changes
julesdesir Feb 13, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 18 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ If you are new to choice modeling, you can check this [resource](https://www.pub

| Dataset | Raw Data | Origin | *from choice_learn.datasets import* | Doc |
| ---------- | :----: | ------ | ------ | :---: |
| SwissMetro | [csv](./choice_learn/datasets/data/swissmetro.csv.gz) | Bierlaire et al. (2001) [[2]](#trident-references) | *load_swissmetro* | [#](https://artefactory.github.io/choice-learn/references/datasets/references_base/#choice_learn.datasets.base.load_swissmetro) |
| SwissMetro | [csv](./choice_learn/datasets/data/swissmetro.csv.gz) | Bierlaire et al. (2001) [[2]](#trident-references) | *load_swissmetro* | [#](https://artefactory.github.io/choice-learn/references/datasets/references_base/#choice_learn.datasets.base.load_swissmetro) |
| ModeCanada | [csv](./choice_learn/datasets/data/ModeCanada.csv.gz) | Forinash and Koppelman (1993) [[3]](#trident-references) | *load_modecanada* | [#](https://artefactory.github.io/choice-learn/references/datasets/references_base/#choice_learn.datasets.base.load_modecanada) |
| Train | [csv](./choice_learn/datasets/data/train_data.csv.gz) | Ben-Akiva et al. (1993) [[5]](#trident-references) |*load_train* | [#](https://artefactory.github.io/choice-learn/references/datasets/references_base/#choice_learn.datasets.base.load_train) |
| Heating | [csv](./choice_learn/datasets/data/heating_data.csv.gz) | Kenneth Train's [website](https://eml.berkeley.edu/~train/) | *load_heating* | [#](https://artefactory.github.io/choice-learn/references/datasets/references_base/#choice_learn.datasets.base.load_heating) |
Expand All @@ -73,18 +73,22 @@ If you are new to choice modeling, you can check this [resource](https://www.pub
| Model | Example | Colab | Related Paper | *from choice_learn.models import* | Doc |
| ---------- | -------- | -------- | ------ | ------ | :---: |
| MNL | [notebook](notebooks/models/simple_mnl.ipynb) | [![Open In Colab](https://img.shields.io/badge/-grey?logo=googlecolab)](https://colab.research.google.com/github/artefactory/choice-learn/blob/main/notebooks/models/simple_mnl.ipynb) | | *SimpleMNL* | [#](https://artefactory.github.io/choice-learn/references/models/references_simple_mnl/) |
| Conditional Logit | [notebook](notebooks/introduction/3_model_clogit.ipynb) | [![Open In Colab](https://img.shields.io/badge/-grey?logo=googlecolab)](https://colab.research.google.com/github/artefactory/choice-learn/blob/main/notebooks/introduction/3_model_clogit.ipynb) | Train et al. [[4]](#trident-references)         | *ConditionalLogit* | [#](https://artefactory.github.io/choice-learn/references/models/references_clogit/) |
| Conditional Logit | [notebook](notebooks/introduction/3_model_clogit.ipynb) | [![Open In Colab](https://img.shields.io/badge/-grey?logo=googlecolab)](https://colab.research.google.com/github/artefactory/choice-learn/blob/main/notebooks/introduction/3_model_clogit.ipynb) | Train et al. [[4]](#trident-references)         | *ConditionalLogit* | [#](https://artefactory.github.io/choice-learn/references/models/references_clogit/) |
| Nested Logit | [notebook](notebooks/models/nested_logit.ipynb) | [![Open In Colab](https://img.shields.io/badge/-grey?logo=googlecolab)](https://colab.research.google.com/github/artefactory/choice-learn/blob/main/notebooks/models/nested_logit.ipynb) | McFadden [[10]](#trident-references) | *NestedLogit* | [#](https://artefactory.github.io/choice-learn/references/models/references_nested_logit/) |
| Latent Class MNL | [notebook](notebooks/models/latent_class_model.ipynb) | [![Open In Colab](https://img.shields.io/badge/-grey?logo=googlecolab)](https://colab.research.google.com/github/artefactory/choice-learn/blob/main/notebooks/models/latent_class_model.ipynb) | | *LatentClassConditionalLogit* | [#](https://artefactory.github.io/choice-learn/references/models/references_latent_class_mnl/) |
| Halo MNL | [notebook](notebooks/models/halo_mnl.ipynb) | [![Open In Colab](https://img.shields.io/badge/-grey?logo=googlecolab)](https://colab.research.google.com/github/artefactory/choice-learn/blob/main/notebooks/models/halo_mnl.ipynb) | Maragheh et al. [[14]](#trident-references) | *HaloMNL* | [#](https://artefactory.github.io/choice-learn/references/models/halo_mnl/) |
| Low-Rank Halo MNL | [notebook](notebooks/models/halo_mnl.ipynb) | [![Open In Colab](https://img.shields.io/badge/-grey?logo=googlecolab)](https://colab.research.google.com/github/artefactory/choice-learn/blob/main/notebooks/models/halo_mnl.ipynb) | Ko and Li [[15]](#trident-references) | *LowRankHaloMNL* | [#](https://artefactory.github.io/choice-learn/references/models/halo_mnl/) |
| Latent Class MNL | [notebook](notebooks/models/latent_class_model.ipynb) | [![Open In Colab](https://img.shields.io/badge/-grey?logo=googlecolab)](https://colab.research.google.com/github/artefactory/choice-learn/blob/main/notebooks/models/latent_class_model.ipynb) | | *LatentClassConditionalLogit* | [#](https://artefactory.github.io/choice-learn/references/models/references_latent_class_mnl/) |
| Halo MNL | [notebook](notebooks/models/halo_mnl.ipynb) | [![Open In Colab](https://img.shields.io/badge/-grey?logo=googlecolab)](https://colab.research.google.com/github/artefactory/choice-learn/blob/main/notebooks/models/halo_mnl.ipynb) | Maragheh et al. [[14]](#trident-references) | *HaloMNL* | [#](https://artefactory.github.io/choice-learn/references/models/halo_mnl/) |
| Low-Rank Halo MNL | [notebook](notebooks/models/halo_mnl.ipynb) | [![Open In Colab](https://img.shields.io/badge/-grey?logo=googlecolab)](https://colab.research.google.com/github/artefactory/choice-learn/blob/main/notebooks/models/halo_mnl.ipynb) | Ko and Li [[15]](#trident-references) | *LowRankHaloMNL* | [#](https://artefactory.github.io/choice-learn/references/models/halo_mnl/) |

| NN-based Model | Example | Colab | Related Paper | *from choice_learn.models import* | Doc |
| NN-based Model | Example | Colab | Related Paper | *from choice_learn.models import* | Doc |
| ---------- | -------- | ------ | ---- | ------ | :---: |
| RUMnet| [notebook](notebooks/models/rumnet.ipynb) | [![Open In Colab](https://img.shields.io/badge/-grey?logo=googlecolab)](https://colab.research.google.com/github/artefactory/choice-learn/blob/main/notebooks/models/rumnet.ipynb) |Aouad and Désir [[1]](#trident-references) | *RUMnet* | [#](https://artefactory.github.io/choice-learn/references/models/references_rumnet/#choice_learn.models.rumnet.PaperRUMnet) |
| TasteNet | [notebook](notebooks/models/tastenet.ipynb) | [![Open In Colab](https://img.shields.io/badge/-grey?logo=googlecolab)](https://colab.research.google.com/github/artefactory/choice-learn/blob/main/notebooks/models/tastenet.ipynb) |Han et al. [[7]](#trident-references) | *TasteNet* | [#](https://artefactory.github.io/choice-learn/references/models/references_tastenet/) |
| Learning-MNL | [notebook](notebooks/models/learning_mnl.ipynb) | [![Open In Colab](https://img.shields.io/badge/-grey?logo=googlecolab)](https://colab.research.google.com/github/artefactory/choice-learn/blob/main/notebooks/models/learning_mnl.ipynb) |Sifringer et al. [[13]](#trident-references) | *LearningMNL* | [#](https://artefactory.github.io/choice-learn/references/models/references_learning_mnl/) |
| ResLogit | [notebook](notebooks/models/reslogit.ipynb) | [![Open In Colab](https://img.shields.io/badge/-grey?logo=googlecolab)](https://colab.research.google.com/github/artefactory/choice-learn/blob/main/notebooks/models/reslogit.ipynb) |Wong and Farooq [[12]](#trident-references) | *ResLogit* | [#](https://artefactory.github.io/choice-learn/references/models/references_reslogit/) |
| RUMnet| [notebook](notebooks/models/rumnet.ipynb) | [![Open In Colab](https://img.shields.io/badge/-grey?logo=googlecolab)](https://colab.research.google.com/github/artefactory/choice-learn/blob/main/notebooks/models/rumnet.ipynb) | Aouad and Désir [[1]](#trident-references) | *RUMnet* | [#](https://artefactory.github.io/choice-learn/references/models/references_rumnet/#choice_learn.models.rumnet.PaperRUMnet) |
| TasteNet | [notebook](notebooks/models/tastenet.ipynb) | [![Open In Colab](https://img.shields.io/badge/-grey?logo=googlecolab)](https://colab.research.google.com/github/artefactory/choice-learn/blob/main/notebooks/models/tastenet.ipynb) | Han et al. [[7]](#trident-references) | *TasteNet* | [#](https://artefactory.github.io/choice-learn/references/models/references_tastenet/) |
| Learning-MNL | [notebook](notebooks/models/learning_mnl.ipynb) | [![Open In Colab](https://img.shields.io/badge/-grey?logo=googlecolab)](https://colab.research.google.com/github/artefactory/choice-learn/blob/main/notebooks/models/learning_mnl.ipynb) | Sifringer et al. [[13]](#trident-references) | *LearningMNL* | [#](https://artefactory.github.io/choice-learn/references/models/references_learning_mnl/) |
| ResLogit | [notebook](notebooks/models/reslogit.ipynb) | [![Open In Colab](https://img.shields.io/badge/-grey?logo=googlecolab)](https://colab.research.google.com/github/artefactory/choice-learn/blob/main/notebooks/models/reslogit.ipynb) | Wong and Farooq [[12]](#trident-references) | *ResLogit* | [#](https://artefactory.github.io/choice-learn/references/models/references_reslogit/) |

| Basket Model | Example | Colab | Related Paper | *from choice_learn.basket_models import* | Doc |
| ---------- | -------- | ------ | ---- | ------ | :---: |
| Deterministic SHOPPER| [notebook](notebooks/basket_models/shopper_tutorial.ipynb) | [![Open In Colab](https://img.shields.io/badge/-grey?logo=googlecolab)](https://colab.research.google.com/github/artefactory/choice-learn/blob/main/notebooks/basket_models/shopper_tutorial.ipynb) | Ruiz et al. [[16]](#trident-references) | *Shopper* | [#](https://artefactory.github.io/choice-learn/references/basket_models/references_shopper/) |


### Auxiliary tools
Expand Down Expand Up @@ -306,7 +310,8 @@ Choice-Learn has been developed through a collaboration between researchers at t
[12] [ResLogit: A residual neural network logit model for data-driven choice modelling](https://doi.org/10.1016/j.trc.2021.103050), Wong, M.; Farooq, B. (2021)\
[13] [Enhancing Discrete Choice Models with Representation Learning](https://arxiv.org/abs/1812.09747), Sifringer, B.; Lurkin, V.; Alahi, A. (2018)\
[14] [A Customer Choice Model with HALO Effect](https://arxiv.org/abs/1805.01603), Maragheh, R., Y.; Chronopoulou, A.; Davis, J., M. (2018)\
[15] [Modeling Choice via Self-Attention](https://arxiv.org/abs/2311.07607), Ko, J.; Li, A., A. (2023)
[15] [Modeling Choice via Self-Attention](https://arxiv.org/abs/2311.07607), Ko, J.; Li, A., A. (2023)\
[16] [SHOPPER: A Probabilistic Model of Consumer Choice with Substitutes and Complements](https://arxiv.org/abs/1711.03560), Ruiz, F. J. R.; Athey, S.; Blei, D. M. (2019)

### Code and Repositories

Expand All @@ -315,4 +320,5 @@ Choice-Learn has been developed through a collaboration between researchers at t
[1] [RUMnet](https://github.com/antoinedesir/rumnet)\
[7] TasteNet [[Repo1](https://github.com/YafeiHan-MIT/TasteNet-MNL)] [[Repo2](https://github.com/deborahmit/TasteNet-MNL)]\
[12] [ResLogit](https://github.com/LiTrans/reslogit)\
[13] [Learning-MNL](https://github.com/BSifringer/EnhancedDCM)
[13] [Learning-MNL](https://github.com/BSifringer/EnhancedDCM)\
[16] [SHOPPER](https://github.com/franrruiz/shopper-src)
6 changes: 6 additions & 0 deletions choice_learn/basket_models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
"""Models classes and functions."""

from .shopper import Shopper
from .trip_dataset import Trip, TripDataset

__all__ = ["Shopper", "Trip", "TripDataset"]
Loading