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

[0.2.2.dev1] New MergedChoiceTable feature: `from_df()` construction #67

Closed mxndrwgrdnr closed 4 years ago

mxndrwgrdnr commented 4 years ago

This is a feature we've wanted for a long time, the ability to create a MergedChoiceTable object from a dataframe. This gives the user the ability to create an mct using the standard choicemodels workflow, but to then extract it, manipulate it, add new terms, and cast it back to an object that can be used by urbansim_templates or choicemodels once again.

My goal was to make as few changes as possible to the core class structure, and as a result my solution is not the most elegant. It relies on the instantiation of two empty dataframes and a wrongly typed class attribute to satisfy what are currently required parameters of the MergedChoiceTable class. I'm open to suggestions if we think there's a better way to achieve the intended result.

coveralls commented 4 years ago

Coverage Status

Coverage increased (+0.3%) to 76.42% when pulling f1ec684bf44858a601006abe42a6935eddc8b35b on mnl_w_mct_df into 54c936d15457923c8ebb5a29b129ce4da8e7e0c7 on master.

smmaurer commented 4 years ago

Thanks @mxndrwgrdnr! It will be great to finally have this. I completely agree with this approach, as we discussed in Slack.

Here are some things i added just now:

If this all looks good, go ahead and merge!

mxndrwgrdnr commented 4 years ago

Looks great, Sam. Thanks for getting it across the finish line.