UDST / choicemodels

Python library for discrete choice modeling
https://udst.github.io/choicemodels
BSD 3-Clause "New" or "Revised" License
74 stars 33 forks source link

Refactor MNL estimation #52

Open smmaurer opened 5 years ago

smmaurer commented 5 years ago

It would be nice to refactor the MNL estimation code, which was originally brought over from urbansim.urbanchoice.mnl. It's been updated in places to provide additional estimation metrics and resolve deprecation warnings, but is mostly unchanged.

The code seems fast and reliable, but it's hard to use, hard to update, and appears to include some partial or extraneous functionality that would be nice to either remove or document and test (e.g. GPU acceleration, estimation weights, latent classes).

Roughly, the pieces are:

1. Probability calculation (mnl_probs)

Already refactored in MultinomialLogitResults.probabilities(), but that version may need to be adapted to accept numpy arrays instead of dataframes for faster iteration in the estimation stage.

2. Likelihood calculation (mnl_loglik)

Hardest part -- can be cleaned up similarly, with dependencies on the PMAT utility removed.

3. Orchestration of maximum likelihood estimation (mnl_estimate)

Pretty straightforward.

4. Calculation of estimation metrics (mnl_estimate)

Pretty straightforward.

5. Simulation (mnl_simulate)

Already refactored; now fully replaced by choicemodels.tools.simulation.

smmaurer commented 5 years ago

May want to look at issue #53 first, in case we can avoid maintaining an estimation codebase entirely.