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

YAML Saving and Loading #20

Merged
merged 17 commits into from
May 14, 2014
Merged

YAML Saving and Loading #20

merged 17 commits into from
May 14, 2014

Conversation

jiffyclub
Copy link
Member

With this RegressionModel and MNLLocationChoiceModel can have their configuration saved to YAML files using .to_yaml methods. Saved configurations can be used to instantiate models using .from_yaml methods. Matching methods for the other model classes will come soon (where applicable).

Another change here is some flexibility in how model expressions can be specified for regressions and location choice models. Previously these had to be strings compatible with patsy, and that's still fine, but now lists and dictionaries can be used. The following are valid and equivalent model expressions:

model_expression = 'np.log(x) ~ x + np.log1p(y)'

model_expression = {
    'left_side': 'np.log(x)',
    'right_side': ['x', 'np.log1p(y)']}

And for right-side only expressions these are all equivalent and valid:

model_expression = 'x + np.log1p(y) + I(z < 1)'

model_expression = ['x', 'np.log1p(y)', 'I(z < 1)']

model_expression = {'right_side': ['x', 'np.log1p(y)', 'I(z < 1)']}

jiffyclub and others added 17 commits May 12, 2014 13:55
A fit RegressionModel stores a statsmodels RegressionResults subclass
and uses that for prediction. (And users can look at the statistics of
the model fit.) For the purposes of storing models on disk all we can
save is the model expression and the fit coefficients.
_FakeRegressionResults can wrap those to provide a RegressionResults
stand in when loading a fit model from a file.
We'll be able to save even a fit model on disk or in a database
as JSON.
also updating the order for the lcm yaml options

added simple_relocation_rate to the location choice model
should have been in the relocation model - didn't notice this at first
Also moved the creation of a dict representation out to its own method.
…tsy string

So that models can be expressed as strings, lists, or dictionaries and
converted to strings for statsmodels/patsy on the fly.
jiffyclub added a commit that referenced this pull request May 14, 2014
YAML Saving and Loading

With this RegressionModel and MNLLocationChoiceModel can have their configuration saved to YAML files using .to_yaml methods. Saved configurations can be used to instantiate models using .from_yaml methods. Matching methods for the other model classes will come soon (where applicable).

Another change here is some flexibility in how model expressions can be specified for regressions and location choice models. Previously these had to be strings compatible with patsy, and that's still fine, but now lists and dictionaries can be used.
@jiffyclub jiffyclub merged commit 592e64c into master May 14, 2014
@jiffyclub jiffyclub deleted the mtc_branch branch May 14, 2014 17:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants