Skip to content

Using a Synthetic Population in Simulations

Specifying a Population and Locations

The epx Python package defines a SynthPop object that allows a user to specify a specific synthetic population (currently, the only option available is "US_2010.v5") and a list of locations to be loaded from that population.

For example, to load Allegheny and Jefferson Counties (in Pennsylvania) from the US 2010 synthetic population, you would create the following SynthPop object:

SynthPop(
    "US_2010.v5", 
    [
        "Allegheny_County_PA",
        "Jefferson_County_PA"
    ]
)

To specify a single location, you would still use a list–one that contains a single entry.

This object is passed as an argument when constructing a ModelConfig object as part of configuring a job.

Selecting Attributes

Attribute Encodings

Race

The numeric values of racial codes are as follows:

Racial Numeric Code Racial Text Code
0 unknown_race
1 white
2 african_american
3 american_indian
4 alaska_native
5 tribal
6 asian
7 hawaiian_native
8 other_race
9 multiple_race

Sex

The numeric values of sex codes are as follows:

Sex Numeric Code Sex Text Code
0 female
1 male

Using the Synthetic Population in Tableau

Connecting Tableau to the SynthPop Database

  1. Select the Explore option on the left hand navigation panel.
  2. Navigate to the folder in which you would like to save the database connection.
  3. Select the Published Data Source from the New dropdown menu in the top left of the window. New dropdown menu with published data source option This will open a window with a tab called Connectors. Connectors tab
  4. Select PostgreSQL from the Connectors tab.
  5. Configure your database connection by providing values for the server, port, and database, as well as your credentials (username and password). Once your credentials are verified, you will be able to view the tables of the database in the left pane. At this point, you may publish your data source to save your connection to the database. Tables pane

Querying the SynthPop Database and Creating a Workbook

In order to create a workbook after connecting to the database, you wull need to specify which data you want to retrieve.

  1. To pull data from the database, double click the New Custom SQL option below the list of database tables in the left pane.
  2. Enter your SQL code in this dialogue box, including any query parameters you would like to use in your notebook. Then, select Ok.
  3. Select the Update Now option in the bottom right pane to see a sample of the results from your SQL query. If you are satisfied with the sample results, click Publish As in the top right of the window. "Publish as" button
  4. To finish publishing your DB connection and run the query, provide a name and select a folder location for the data, then navigate to the selected folder.
    Note: The first Tableau design interface you see after publishing is a scratchpad associated with the new data source. This is intended for testing the output of your connection; work should be saved there.
  5. Once you navigate to the folder location containing the data, select and then New Workbook. You will be prompted to renter your database credentials (not your Tableau credentials).
  6. Your workbook now contains the results of the SQL query. You can drag and drop variables to create visualizations before publishing this workbook for others to see!
    Note: If you used a parameterized query, you will need to set the value of your parameter(s) before your results data can be pulled into the workbook.