from urbansim.models import SegmentedMNLDiscreteChoiceModel


seg_col = 'income_3_tenure'
sample_size = 100
prob_mode = 'single_chooser'
choice_mode = 'aggregate'
choice_col = 'zone_id'
default_model_expr = 'ln_avg_unit_price_zone + median_age_of_head + median_yearbuilt_post_1990 ' \
                     '+ percent_renter_hh_in_zone + townhome + jobs_within_45min'

remove_alts = False
#alts_filter = ['residential_units > 0']

hlcm = SegmentedMNLDiscreteChoiceModel(segmentation_col=seg_col, sample_size=sample_size,
                                       probability_mode=prob_mode, choice_mode=choice_mode,
                                       choice_column=choice_col, default_model_expr=default_model_expr)


alts = orca.get_table('zones').to_frame()
alts = alts.fillna(0)


### define models
# model1 = 'ln_dist_rail + ln_avg_unit_price_zone + median_age_of_head + median_yearbuilt_post_1990' \
#          ' + percent_hh_with_child_x_hh_with_child + percent_renter_hh_in_zone' \
#          ' +  townhome + multifamily + jobs_within_45min + parks_3mi + golf_courses_3mi + schools_3mi + ' \
#          'fast_food_3mi + restauraunt_3mi + supermarket_3mi + cafes_3mi'
#
# model2 = 'ln_dist_rail + income5xlt_x_avg_unit_price_zone + median_age_of_head + median_yearbuilt_post_1990' \
#          ' + median_yearbuilt_pre_1950 + percent_hh_with_child_x_hh_with_child + percent_renter_hh_in_zone' \
choice_mode = "aggregate"
choice_col = "zone_id"
default_model = (
    "ln_avg_nonres_unit_price_zone+non_residential_sqft_zone+ln_residential_unit_density_zone"
    "+ln_avg_unit_price_zone+median_age_of_head+mean_income+jobs_within_45min+ln_jobs_within_30min"
)

alts_filter = ["non_residential_sqft > 0"]

remove_alts = False

elcm = SegmentedMNLDiscreteChoiceModel(
    segmentation_col=seg_col,
    sample_size=sample_size,
    probability_mode=prob_mode,
    choice_mode=choice_mode,
    choice_column=choice_col,
    default_model_expr=default_model,
    alts_fit_filters=None,
)


# alts = orca.get_table('alts_elcm').to_frame()
alts = orca.get_table("zones").to_frame()
choosers = establishments_for_estimation


##define models
model11 = (
    "ln_jobs_within_30min+ln_avg_nonres_unit_price_zone+median_year_built+ln_residential_unit_density_zone"
    "+ln_pop_within_20min+nonres_far+office+retail_or_restaurant+industrial_building"
Beispiel #3
0
seg_col = 'sector_id_retail_agg'
prob_mode = 'single_chooser'
choice_mode = 'aggregate'
choice_col = 'zone_id'

default_model = 'ln_avg_nonres_unit_price_zone+non_residential_sqft_zone+ln_residential_unit_density_zone' \
                '+ln_avg_unit_price_zone+median_age_of_head+mean_income+jobs_within_45min+ln_jobs_within_30min'

alts_filter = ['non_residential_sqft > 0']

remove_alts = False

elcm = SegmentedMNLDiscreteChoiceModel(segmentation_col=seg_col,
                                       sample_size=sample_size,
                                       probability_mode=prob_mode,
                                       choice_mode=choice_mode,
                                       choice_column=choice_col,
                                       default_model_expr=default_model,
                                       alts_fit_filters=None)

#alts = orca.get_table('alts_elcm').to_frame()
alts = orca.get_table('buildings').to_frame().fillna(0)
choosers = establishments_for_estimation.fillna(0)

results = elcm.fit(choosers, alts, current_choice='building_id')
elcm.to_yaml('c:/urbansim2/urbansim/urbansim_drcog/config/elcm_yaml.yaml')

##define models
# model11 = 'ln_jobs_within_30min+ln_avg_nonres_unit_price_zone+median_year_built+ln_residential_unit_density_zone' \
#                 '+ln_pop_within_20min+nonres_far+office+retail_or_restaurant+industrial_building' \
#                 '+employees_x_ln_non_residential_sqft_zone+ln_dist_rail+rail_within_mile'