Skip to content

Instantly share code, notes, and snippets.

@smmaurer
Last active July 25, 2018 22:00
Show Gist options
  • Save smmaurer/5bdffb55ba135686c670c12d7f38d7f2 to your computer and use it in GitHub Desktop.
Save smmaurer/5bdffb55ba135686c670c12d7f38d7f2 to your computer and use it in GitHub Desktop.
import orca
import pandas as pd
from urbansim_templates import modelmanager as mm # Orca extension for managing template steps
from urbansim_templates.models import BinaryLogitStep
mm.initialize() # load any saved steps from the local project directory
df = pd.read_csv('households.csv')
orca.add_table('households', df)
m = BinaryLogitStep() # start building a template-based model step
m.tables = ['households']
m.model_expression = 'recent_mover ~ age + cost_burden + tenure'
m.fit() # estimate a logit model and display the results
m.out_column = 'unit_id' # in the simulation, predicting a move means
m.out_value_true = -1
m.name = 'household-relocation-v1'
m.register() # register the model step with Orca, and save it to disk for later use
mm.list_steps()
orca.run(['real-estate-price-model', 'household-relocation-v1', 'household-location-choice'])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment