Skip to main content

us-home-safety-score

Compute residential Home Safety Scores (0-100, A-F) from U.S. federal data. Zero dependencies. Pure Python 3.9+.

PyPI License: MIT Python 3.9+ DOI

This is the Python port of the us-home-safety-score npm package. Both implementations produce identical scores for the same inputs (verified bit-for-bit across a 640-case grid, including rounding edge cases).

The Home Safety Score is a composite index that evaluates environmental risk for any U.S. ZIP code across four dimensions:

  • Water quality — EPA SDWIS violation history
  • Lead exposure — EPA Lead and Copper Rule sampling
  • Radon risk — EPA county-level radon zones
  • Flood risk — FEMA NFIP historical claims

Higher score = safer. It is the same algorithm used on ZipCheckup.com to score tens of thousands of ZIP codes.

Install

pip install us-home-safety-score

Quick Start

from us_home_safety_score import compute_safety_score

result = compute_safety_score({
    "totalViolations": 3,
    "healthViolations": 1,
    "leadLevel": 0.008,     # mg/L (90th percentile)
    "radonZone": 2,         # EPA zone: 1=High, 2=Moderate, 3=Low
    "floodClaims": 25,      # FEMA NFIP historical claims
})

print(result)
# {
#   'score': 67,
#   'grade': 'C',
#   'components': {
#     'water': {'score': 21, 'maxPoints': 25, 'weight': 0.25},
#     'lead':  {'score': 18, 'maxPoints': 25, 'weight': 0.25},
#     'radon': {'score': 13, 'maxPoints': 25, 'weight': 0.25},
#     'flood': {'score': 15, 'maxPoints': 25, 'weight': 0.25},
#   },
#   'componentCount': 4,
# }

Field names use camelCase (totalViolations, leadLevel, floodClaims, …) to stay 1:1 with the npm package's input contract.

Scoring

Component Weight Max Points Source
Water quality 25% (or 33%) 25 (or 33) EPA SDWIS violations, past 5 years
Lead/copper 25% (or 33%) 25 (or 33) EPA Lead and Copper Rule, 90th-percentile
Radon 25% (or 33%) 25 (or 33) EPA county radon zones
Flood 25% 25 FEMA NFIP claims count

When FEMA flood data is unavailable, the score falls back to a 3-component mode (each component worth 33 points instead of 25). Missing lead or radon data uses a neutral assumption (2/3 of max points) rather than penalizing or rewarding the location.

Grade thresholds: A ≥ 85, B ≥ 70, C ≥ 55, D ≥ 40, F < 40.

Full methodology: https://zipcheckup.com/about/home-safety-score/

API

Function Returns
compute_safety_score(data) {score, grade, components, componentCount}
compute_lead_risk(data) {risk, probability, exceedsActionLevel, description}
compute_flood_risk(data) {risk, estimatedAnnualCost, claims, description}
compute_compliance_risk(data) {risk, score, unresolved, description}
compute_energy_burden(data) {burden, risk, description}
score_to_grade(score) 'A' … 'F'
from us_home_safety_score import compute_lead_risk

compute_lead_risk({"leadLevel": 0.020})
# {'risk': 'high', 'probability': 0.85, 'exceedsActionLevel': True,
#  'description': 'Lead level exceeds the EPA action level (15 ppb). ...'}

Data sources

  • EPA SDWIS — Safe Drinking Water Information System (violations, Lead and Copper Rule sampling)
  • EPA Radon Zones — county-level radon potential map
  • FEMA NFIP — National Flood Insurance Program claims

This package contains only the scoring logic — you supply the federal data inputs. Pre-joined per-ZIP data is available via the us-water-quality-data package and the ZipCheckup API.

License

MIT © ZipCheckup

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

us_home_safety_score-1.0.2.tar.gz (11.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

us_home_safety_score-1.0.2-py3-none-any.whl (8.7 kB view details)

Uploaded Python 3

File details

Details for the file us_home_safety_score-1.0.2.tar.gz.

File metadata

  • Download URL: us_home_safety_score-1.0.2.tar.gz
  • Upload date:
  • Size: 11.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for us_home_safety_score-1.0.2.tar.gz
Algorithm Hash digest
SHA256 2d11a3928b03413873588d80ef4259edf67fd6a0eaa2f0a9cab640963d883850
MD5 b3ae3fa5211087ca75e549e81c718a68
BLAKE2b-256 83478db54df6dcf2a7fda8a64dbefa7b076b2a858e4e1f7f7bcc4efc8f954a72

See more details on using hashes here.

File details

Details for the file us_home_safety_score-1.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for us_home_safety_score-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 52360add1a6dae744a030ef87e501d75c43ab6579d972881354277d33662eb52
MD5 bfdba6894ddbacdc439f85aeef904017
BLAKE2b-256 83d1881cb068df69332c6516553dac86b6f4f3411240ec7abe7460c10e51bd24

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

1.0.2 This release

2 files

1.0.1

2 files

1.0.0

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page