<jupyter_start><jupyter_text>Testing a Change in the Auto Owernship ModelCreate two auto ownership examples to illustrate running two scenarios and analyzing results.  This notebook assumes users are familiar with the [Getting Started](getting_started.ipynb) notebook.  Create two examples<jupyter_code>!activitysim create -e example_mtc -d example_base_auto_own

!activitysim create -e example_mtc -d example_base_auto_own_alternative<jupyter_output>copying data ...
copying configs ...
copying configs_mp ...
copying output ...
copying README.MD ...
copied! new project files are in C:\projects\development\activitysim_rsg\notebooks\example_base_auto_own\example_mtc
the copied example can be run with

  activitysim run -w example_base_auto_own\example_mtc
copying data ...
copying configs ...
copying configs_mp ...
copying output ...
copying README.MD ...
copied! new project files are in C:\projects\development\activitysim_rsg\notebooks\example_base_auto_own_alternative\example_mtc
the copied example can be run with

  activitysim run -w example_base_auto_own_alternative\example_mtc<jupyter_text>Run base example<jupyter_code>%cd example_base_auto_own

!activitysim run -c configs -d data -o output

#return to root folder
%cd ..<jupyter_output>C:\projects\development\activitysim_rsg\notebooks\example_base_auto_own
Configured logging using basicConfig
INFO:activitysim:Configured logging using basicConfig
INFO:activitysim.cli.run:using configs_dir: ['configs']
INFO:activitysim.cli.run:using data_dir: ['data']
INFO:activitysim.cli.run:using output_dir: ['output']
INFO - Read logging configuration from: configs\logging.yaml
INFO - setting households_sample_size: 100
INFO - setting chunk_size: 0
INFO - setting multiprocess: None
INFO - setting num_processes: None
INFO - setting resume_after: None
INFO - run single process simulation
INFO - open_pipeline
INFO - Set random seed base to 0
INFO - Time to execute open_pipeline : 0.016 seconds (0.0 minutes)
INFO - preload_injectables
INFO - Time to execute preload_injectables : 0.0 seconds (0.0 minutes)
INFO - Reading CSV file data\land_use.csv
INFO - renaming columns: {'ZONE': 'TAZ', 'COUNTY': 'county_id'}
INFO - keeping columns: ['DISTRICT', 'SD', 'county_id', 'TOTHH', 'TOTPOP', 'TOT[...]<jupyter_text>Run alternative example with no input differences<jupyter_code>%cd example_base_auto_own_alternative

!activitysim run -c configs -d data -o output

#return to root folder
%cd ..<jupyter_output>C:\projects\development\activitysim_rsg\notebooks\example_base_auto_own_alternative
Configured logging using basicConfig
INFO:activitysim:Configured logging using basicConfig
INFO:activitysim.cli.run:using configs_dir: ['configs']
INFO:activitysim.cli.run:using data_dir: ['data']
INFO:activitysim.cli.run:using output_dir: ['output']
INFO - Read logging configuration from: configs\logging.yaml
INFO - setting households_sample_size: 100
INFO - setting chunk_size: 0
INFO - setting multiprocess: None
INFO - setting num_processes: None
INFO - setting resume_after: None
INFO - run single process simulation
INFO - open_pipeline
INFO - Set random seed base to 0
INFO - Time to execute open_pipeline : 0.004 seconds (0.0 minutes)
INFO - preload_injectables
INFO - Time to execute preload_injectables : 0.0 seconds (0.0 minutes)
INFO - Reading CSV file data\land_use.csv
INFO - renaming columns: {'ZONE': 'TAZ', 'COUNTY': 'county_id'}
INFO - keeping columns: ['DISTRICT', 'SD', 'county_id', 'TOTHH', 'T[...]<jupyter_text>Confirm identical results before making changes to the alternative scenario<jupyter_code>import pandas as pd

hh_base = pd.read_csv("example_base_auto_own/output/final_households.csv")
hh_alt = pd.read_csv("example_base_auto_own_alternative/output/final_households.csv")

same_results = (hh_base.auto_ownership == hh_alt.auto_ownership).all()

print("Identical household auto ownership results base versus alternative scenario: " + str(same_results))<jupyter_output>Identical household auto ownership results base versus alternative scenario: True<jupyter_text>Modify the alternative scenarioReduce young adult car ownership coefficient to simulate the idea of less car ownership among young adults<jupyter_code>adjustment_factor = -2
coefficient_of_interest = "coef_cars1_persons_25_34"

alt_expressions = pd.read_csv("example_base_auto_own/configs/auto_ownership_coeffs.csv")

row_selector = (alt_expressions["coefficient_name"] == "coef_cars1_persons_25_34")

print(alt_expressions.loc[row_selector])

alt_expressions.loc[row_selector,"value"] = alt_expressions.loc[row_selector,"value"] + adjustment_factor

alt_expressions.to_csv("example_base_auto_own_alternative/configs/auto_ownership_coeffs.csv")

print(alt_expressions.loc[row_selector])<jupyter_output>coefficient_name  value constrain
4  coef_cars1_persons_25_34    0.0         T
           coefficient_name  value constrain
4  coef_cars1_persons_25_34   -2.0         T<jupyter_text>Re-run alternative example<jupyter_code>%cd example_base_auto_own_alternative

!activitysim run -c configs -d data -o output

#return to root folder
%cd ..<jupyter_output>C:\projects\development\activitysim_rsg\notebooks\example_base_auto_own_alternative
Configured logging using basicConfig
INFO:activitysim:Configured logging using basicConfig
INFO:activitysim.cli.run:using configs_dir: ['configs']
INFO:activitysim.cli.run:using data_dir: ['data']
INFO:activitysim.cli.run:using output_dir: ['output']
INFO - Read logging configuration from: configs\logging.yaml
INFO - setting households_sample_size: 100
INFO - setting chunk_size: 0
INFO - setting multiprocess: None
INFO - setting num_processes: None
INFO - setting resume_after: None
INFO - run single process simulation
INFO - open_pipeline
INFO - Set random seed base to 0
INFO - Time to execute open_pipeline : 0.016 seconds (0.0 minutes)
INFO - preload_injectables
INFO - Time to execute preload_injectables : 0.011 seconds (0.0 minutes)
INFO - Reading CSV file data\land_use.csv
INFO - renaming columns: {'ZONE': 'TAZ', 'COUNTY': 'county_id'}
INFO - keeping columns: ['DISTRICT', 'SD', 'county_id', 'TOTHH', [...]<jupyter_text>Compare ResultsPlot the difference in household auto ownership.  For additional summaries for downstream models, see the [Summarizing Results](summarizing_results.ipynb) notebook.<jupyter_code>import matplotlib.pyplot as plt

#read and summarize data
hh_base = pd.read_csv("example_base_auto_own/output/final_households.csv")
hh_alt = pd.read_csv("example_base_auto_own_alternative/output/final_households.csv")

autos_base = hh_base["auto_ownership"].value_counts()
autos_alt = hh_alt["auto_ownership"].value_counts()

#create plot
%matplotlib inline
plt.style.use('ggplot')
plt.rcParams['figure.figsize'] = (15,10)

plt.bar(x=autos_base.index - 0.15, height=autos_base.values, width=0.25, label="base", color="lightseagreen")
plt.bar(x=autos_alt.index + 0.15, height=autos_alt.values, width=0.25, label="alt", color="dodgerblue")

plt.title('Auto Ownership By Household')
plt.ylabel('Number of Households')
plt.legend()
plt.xticks(autos_base.index.values, autos_alt.index.values)
_ = plt.xlabel('Number of Vehicles')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.09497907949790795, 'fraction_numerical': 0.012552301255230125, 'mean_word_length': 6.22883064516129, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '7', 'dir': 'jupyter-structured-clean-dedup', 'id': '497593', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 2353, 'n_tokens_neox': 2275, 'n_words': 596, 'path': 'activitysim/examples/example_mtc/notebooks/change_in_auto_ownership.ipynb', 'repo_name': 'mattwigway/activitysim', 'size': '7170'}