timothyb0912 / pylogit

A python package for estimating conditional logit models.
https://pypi.org/project/pylogit/
BSD 3-Clause "New" or "Revised" License
187 stars 103 forks source link

PyTorch as computational backend #51

Open timothyb0912 opened 4 years ago

timothyb0912 commented 4 years ago

Request

Currently, PyLogit is built atop numpy and scipy.sparse for computational of choice probabilities, gradients, and hessians. This computational backend has at least two problems.

  1. It restricts us to analytical derivatives that must be programmed by hand.
  2. It practically restricts us to batch optimization since stochasatic optimization methods are currently only in libraries with automatic differentiation support.

Note, packages such as autograd and jax are of no help here because they don't support sparse matrices.

PyLogit should move to using PyTorch as its computational backend. There are almost no immediately known downsides. Upsides include resolving both problems above, allowing essentially arbitrary chocie models to be estimated through PyLogit, and providing access to a large and growing ecosystem of tools that are all designed around PyTorch (e.g. for model serialization, for scikit-learn compatibility, for standardization of model estimation code by end users, etc.).

danhphan commented 3 years ago

Hi @timothyb0912, how is the progress of this feature going?

I am currently using pylogit for the mnl estimation of a large data set (million rows) with a large number of alternatives. I have some experience with pytorch, and would like to integrate pytorch's mini-batch optimization into pylogit.

Should we develop another estimation.py file in pylogit? Do you have a plan for this feature or any advice where I should start?

Really appreciate your help!

Thank you.