Skip to main content

Urban System Generator (USG)

License PyPI

NLR Software Record: SWR 25-36

Urban System Generator (USG) completes missing residential building characteristics for URBANopt projects with machine-learning models trained on NREL ResStock. Give it an URBANopt GeoJSON, or a CSV with whatever you know about each building. It returns a complete, validated URBANopt-BuildStock mapping CSV, with a confidence report for every predicted value and a report of everything post-processing changed.

Version 1.1 ships new national models and restores the attributes they no longer predict. Output columns and the CLI are unchanged; see the changelog. Upgrading from 0.1.x is covered here.

Features

  • Two pretrained national models:

    • G-NN gives the most accurate value per building, in one pass. It is the default.
    • TabDDPM, a tabular diffusion model, draws complete buildings from the joint distribution. It is considerably slower — see choosing a model.

    Both were trained on all 549,715 ResStock 2024.2 buildings and ship inside the package, so everything works offline.

  • Choose how a prediction becomes a value with --decode. argmax takes the most likely value, which is the best guess for one building but repeats it across a district. sample draws in proportion to the predicted probabilities, so a district keeps the stock's real mix of equipment and insulation.

  • Location-aware. The state comes from the weather filename, the climate zones from the Site Origin's nearest ResStock weather station, and County and PUMA from the Site Origin's nearest Census tract.

  • GeoJSON mapping of URBANopt building properties to ResStock parameters.

  • Post-processing to URBANopt-BuildStock:

    • what your own inputs already determine is filled before the model is asked, and a value that contradicts the stock is reported rather than overwritten;
    • attributes the models do not predict — constants, duplicates of another column, and exact functions of other columns — are restored by table lookup, verified against every building in the release;
    • remaining required columns are derived from ResStock, consistently with the known and predicted attributes;
    • values are validated against options_lookup.tsv and consistency rules are applied;
    • a report records every change.
  • Confidence reports (HTML/JSON) for every predicted value, calibrated on held-out ResStock buildings.

  • Reproducible runs. Every run writes run_manifest.json with the model checksums, seed and versions.

Install

pip install urban-system-generator            # Python 3.10+; CPU PyTorch is enough
usg --version

From source:

git clone https://github.com/NatLabRockies/urban-system-generator.git
cd urban-system-generator
pip install -e ".[dev]"

Quickstart

# GeoJSON -> URBANopt-ready CSV + confidence and post-processing reports
usg workflow -i buildings.json -o uo_buildstock_mapping.csv

# Same project with the diffusion model
usg workflow -i buildings.json -o uo_buildstock_mapping.csv --model tabddpm --samples 32

# Complete a CSV of partially known buildings
usg complete -i incomplete.csv -o completed.csv

# One building, with confidence and the most likely alternatives
usg predict-single -a "Geometry Building Type RECS" "Single-Family Detached" -a Vintage 1990s -a State CO

# Post-process an existing completed CSV
usg process -i completed.csv -o uo_buildstock_mapping.csv -g buildings.json
Location: MD (weather file) · 4A (nearest station) · Mixed-Humid (from 4A) · South Atlantic (from state) · nearest station Baltimore Blt Washngtn IntL (16 km) · County and PUMA G2405100, G24000804 (Site Origin, nearest Census tract 0.2 km)
Model: gnn-national-2024.2-v2 — state MD from weather file (USA_MD_Baltimore-Washington.Intl.AP.724060_TMY3.epw); model type gnn (default for MD); the national gnn model is the recommended model for MD; gnn-national-2024.2-v2 (embedded)
Converted 77 residential building(s) from buildings.json
...
Confidence: mean 0.65, expected accuracy 0.68 — 1652 high / 1230 medium / 1507 low predicted values
✓ Confidence report: confidence_report.html
Post-processing changed 0 of 7,700 predicted values (0.0%) and 0 of your 924 input values; filled 0 empty cells and added 45 required columns the model does not predict
✓ Post-processing report: postprocess_report.html
✓ Workflow complete!

Outputs next to the CSV:

  • the final mapping;
  • confidence_report.{json,html};
  • postprocess_report.{json,html} and postprocess_changes.csv: every value post-processing changed, and why;
  • run_manifest.json;
  • <name>_input_issues.csv if some input values were not valid options;
  • schema_validation_report.csv and consistency_audit_report.csv, when there are issues.

A run is flagged for review when post-processing changes more than 5% of predicted values or any of your inputs.

Full reference: docs/cli_usage.md.

Models

Model --model Best for
gnn-national-2024.2-v2 (default) gnn the most accurate value for each building
tabddpm-national-2024.2-v2 tabddpm draws from the joint distribution; ~3,200 network passes per building, so far slower than the G-NN. For variety across a district, --decode sample on the G-NN is usually the better trade
  • Training data: all 549,715 ResStock 2024.2 baseline buildings (48 states + DC).
  • Inputs: the building's location (state, climate zones, census division), so one model serves every state.
  • Evaluation: usg models list shows the headline test results, and usg models info <model id> --card shows each model's full held-out evaluation.

Confidence reports

Every workflow and complete run writes confidence_report.json and confidence_report.html. Skip them with --no-confidence-report. For each predicted value, the report gives:

  • the chance it is right, given what you supplied for that building;
  • the expected accuracy for buildings with the same inputs;
  • the inputs that drove it;
  • the missing GeoJSON properties (e.g. year_built, system_type) that would raise it most.

The confidence comes from small models precomputed on held-out buildings and shipped inside each model bundle, so it costs well under a second per 100 buildings. See docs/confidence_reports.md.

Model selection

You pass Model used
nothing the default model (G-NN) recommended for the project's state
--model tabddpm that model type
--model-id tabddpm-national-2024.2-v2 exactly that model
--model-dir path/to/bundle that local bundle

The selected model and the reason are always printed and recorded in run_manifest.json. Details: docs/models.md.

Location

The models take five location inputs. Every building of a GeoJSON project gets the same location, read only from the weather filename and the Site Origin point:

Input Source
State --state XX > weather filename (USA_MD_… → MD) > the Site Origin's nearest ResStock weather station
ASHRAE IECC Climate Zone 2004 --climate-zone > the Site Origin's nearest station > the state's zone when ≥ 90% of its homes share it
Building America Climate Zone implied by the ASHRAE zone when the data allows > the Site Origin's nearest station > the state's zone
Census Division the state
PUMA Metro Status only when you provide it (CSV column or -a)

County and PUMA is used by post-processing and is not a model input. It comes from the 2010 Census tract nearest to the Site Origin, within the project's state; the tract table is packaged, so no network access is needed. County, PUMA, City, AHS Region, ISO/RTO and the other location columns are then derived from it.

For CSV input, latitude/longitude columns locate each row when the CSV has no State values. Details: docs/location.md.

Python API

from usg import ModelRequest, resolve, run_workflow
from usg.pipeline import ConfidenceOptions, complete_dataframe, load_model
import pandas as pd

result = run_workflow("buildings.json", "uo_buildstock_mapping.csv", ModelRequest(), confidence_report=True)

imputer = load_model(resolve(ModelRequest(state="CO", model_type="gnn")))
df = pd.DataFrame([{"Building": "b1", "State": "CO", "Vintage": "1990s"}])
completion = complete_dataframe(df, imputer, confidence=ConfidenceOptions())
print(completion.data.T, completion.records[0]["confidence"]["attributes"]["Heating Fuel"])
print(imputer.impute(df).top_k("Heating Fuel", 3))

URBANopt integration

URBANopt can call usg workflow from Ruby:

  • inference is single-threaded by default to avoid thread-pool hangs in subprocesses (change it with --threads or USG_NUM_THREADS);
  • exit codes distinguish model selection (3), bundle (4) and input (5) errors;
  • model downloads use file locks, so parallel runs share the cache safely.

Documentation

Development

pip install -e ".[dev]"
pytest                                   # unit, CLI and end-to-end tests (tiny bundles are built at test time)
ruff check src tests
python scripts/fetch_embedded_bundles.py # copy the registry's embedded model bundles before building a wheel

Models are trained, calibrated and exported with NLR's model training pipeline.

Authors & Contributors

Lead Developer: Rawad El Kontar

Organization: National Laboratory of the Rockies (NLR)

Contributing

Contributions are welcome. Please fork the repository, create a feature branch, add tests for your changes and open a pull request.

License

Copyright (c) 2025-2026, Alliance for Energy Innovation, LLC

This project is licensed under the BSD 3-Clause License; see LICENSE and NOTICE. Model weights are trained on NREL ResStock data (CC-BY-4.0) and distributed under the license stated in each bundle's manifest and model card.

Citation

If you use this software in your research, please cite:

@software{urban_system_generator,
  title={Urban System Generator},
  author={El Kontar, Rawad},
  organization={National Laboratory of the Rockies},
  version={1.0.0},
  year={2026},
  url={https://github.com/NatLabRockies/urban-system-generator}
}

Acknowledgments

This work was authored by the National Laboratory of the Rockies (NLR) for the U.S. Department of Energy (DOE), operated under Contract No. DE-AC36-08GO28308. Funding provided by NLR's Laboratory Directed Research and Development program, and the DOE Office of Science. The views expressed in the article do not necessarily represent the views of the DOE or the U.S. Government. The U.S. Government retains and the publisher, by accepting the article for publication, acknowledges that the U.S. Government retains a nonexclusive, paid-up, irrevocable, worldwide license to publish or reproduce the published form of this work, or allow others to do so, for U.S. Government purposes.

Contact

For questions or support, please contact Rawad El Kontar (rawad.elkontar@nlr.gov) or open an issue on GitHub.


NLR Software Record: SWR 25-36

Metadata

Release files for urban-system-generator 1.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for urban-system-generator 1.1.1
File Size Uploaded Provenance Actions
urban_system_generator-1.1.1.tar.gz 26.3 MB Without provenance Details for urban_system_generator-1.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for urban-system-generator 1.1.1
File Interpreter ABI Platform Actions
urban_system_generator-1.1.1-py3-none-any.whl Python 3 none any Details for urban_system_generator-1.1.1-py3-none-any.whl

Total release size: 52.6 MB

Release files / urban_system_generator-1.1.1.tar.gz

Download URL urban_system_generator-1.1.1.tar.gz
Size 26.3 MB
Tags Source
SHA-256 checksum
How to use checksums
c5a6bc1a6e0bdcda2f9f65ebc44315556e8e1b16e6f7aa59691572170ee4186e
BLAKE2b-256 checksum
How to use checksums
c6dd2e5b960cbc78f33d38f816fe5d9959278ac308ea9d898221711c04e839ea
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.7

Release files / urban_system_generator-1.1.1-py3-none-any.whl

Download URL urban_system_generator-1.1.1-py3-none-any.whl
Size 26.3 MB
Tags Python 3
SHA-256 checksum
How to use checksums
6e638ec325706ea57475f887fe12f2c81036434346745b876e7609b82e3890df
BLAKE2b-256 checksum
How to use checksums
88102159aae54374c9311ad1f9c1b4b146774b35f5450cee954cc8610ae87f59
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.7

Security for urban-system-generator 1.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page