Skip to main content

HMDA mortgage lending disparity analyzer — denial rates, racial disparities, lending deserts, and lender benchmarking

Project description

hmda-analyzer 📊

HMDA mortgage lending disparity analyzer.

Compute denial rate disparities by race, identify lending deserts, benchmark lenders against peers, and generate fair lending analysis reports — using CFPB HMDA LAR data. Free public API, no authentication required.


Why hmda-analyzer?

HMDA data covers 10+ million mortgage applications per year with borrower demographics, denial rates, loan amounts, and census tract locations. It is the most powerful public dataset for analyzing mortgage lending disparities — but it requires significant engineering to use. hmda-analyzer makes it accessible in Python.


Installation

pip install hmda-analyzer

Both of these import styles work after installation:

from hmdaanalyzer import denial_rate_by_race   # canonical form
from hmda_analyzer import denial_rate_by_race   # pip-name convention alias

Quickstart

from hmdaanalyzer import (
    load_sample, denial_rate_by_race, disparity_ratio,
    lending_by_tract, lending_desert_score, lender_summary,
    generate_disparity_report,
)

# Load sample data (no API required)
df = load_sample(n=5000)

# Or load from CFPB API — streams and stops at limit rows
# df = load_from_api(year=2023, state="IL", limit=10_000)

# Denial rates by race
rates = denial_rate_by_race(df)
print(rates)

# Disparity ratios vs White applicants
disparities = disparity_ratio(df)
print(disparities)

# Geographic analysis — lending activity by census tract
tracts = lending_by_tract(df)
print(tracts.head())

# Lending desert identification — tracts with abnormally low application volume
deserts = lending_desert_score(df)
print(deserts.head())

# Lender analysis
summary = lender_summary(df, lei="LEI000001")

# Full disparity report
report = generate_disparity_report(df, title="Illinois Mortgage Market 2023")
print(report)

Analyses Supported

  • Denial rate by race and ethnicity
  • Disparity ratios vs reference group (default: White applicants)
  • Denial rate by income band
  • Denial reasons by race
  • Lending activity by census tract, county, and state
  • Lending desert identification (low application volume tracts)
  • Lender vs market comparison
  • Top lenders by origination volume

Error Handling

If you pass a DataFrame that is missing a column an analysis requires, the function raises MissingColumnError (importable from hmdaanalyzer or hmda_analyzer) instead of silently returning an empty result. In a fair-lending context a silent empty result can read as "no disparity," so a schema problem fails loudly:

from hmdaanalyzer import MissingColumnError, lending_by_state

try:
    lending_by_state(df)            # df has 'state' but not 'state_code'
except MissingColumnError as e:
    print(e)                        # names the function and the missing column

MissingColumnError subclasses ValueError, so existing except ValueError handlers keep working. This applies to the analysis functions and to filtering arguments: passing lei=... or state=... when that column is absent raises rather than silently computing whole-market results. A well-formed query that simply matches no rows is not an error — e.g. lender_summary(df, lei=...) with a valid schema but an unknown LEI still returns an empty {}, and generate_disparity_report(df, lei=...) returns a clean no-records report.

Breaking change in 0.3.0: functions that previously returned an empty result on a missing column now raise MissingColumnError. See the CHANGELOG for the full list.


Disparity Ratio Thresholds

Based on CFPB fair lending examination standards:

  • = 2.0x — HIGH disparity (triggers regulatory scrutiny)

  • = 1.5x — MODERATE disparity

  • < 1.5x — LOW disparity
  • < 1.0x — FAVORABLE (group has lower denial rate than reference)

Data Sources

CFPB HMDA Data Browser API — free, no API key required. 2024 data covers 4,908 institutions and millions of loan applications.

https://ffiec.cfpb.gov/data-browser/

Running Tests

PYTHONPATH=. pytest tests/ -v

35 tests across all modules.


Who This Is For

  • Fair lending analysts and compliance teams at banks and CDFIs
  • Community reinvestment researchers studying mortgage disparities
  • Journalists covering housing discrimination and redlining
  • Regulators and examiners analyzing lender performance
  • Academics studying racial wealth gaps and homeownership barriers

License

MIT 2026 Jaypatel1511

Project details


Download files

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

Source Distribution

hmda_analyzer-0.3.0.tar.gz (18.4 kB view details)

Uploaded Source

Built Distribution

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

hmda_analyzer-0.3.0-py3-none-any.whl (17.1 kB view details)

Uploaded Python 3

File details

Details for the file hmda_analyzer-0.3.0.tar.gz.

File metadata

  • Download URL: hmda_analyzer-0.3.0.tar.gz
  • Upload date:
  • Size: 18.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for hmda_analyzer-0.3.0.tar.gz
Algorithm Hash digest
SHA256 53b4ad4cd8d08ad168dd42fd23060d0551f5a0a2a0943c0d56d27104dbc483a4
MD5 bc51fdbf3fcf78a7e8e7fbca5bf3d92f
BLAKE2b-256 618f9bd82c4bfb25ae202688097929258b0744d3d8dd61e71372bb6f5dca4499

See more details on using hashes here.

Provenance

The following attestation bundles were made for hmda_analyzer-0.3.0.tar.gz:

Publisher: release.yml on Jaypatel1511/hmda-analyzer

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file hmda_analyzer-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: hmda_analyzer-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 17.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for hmda_analyzer-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d8a50c3e353eb2affe629ca42a7f4ee601c22354cc916108039b7d14f1a3dc56
MD5 9804f0de8d97f5d2afea8e0bcb6ba034
BLAKE2b-256 c30ecbe4beb71f10d4c68878c5e7283c9adc9f1aef88dbf49048e8dc07f7638b

See more details on using hashes here.

Provenance

The following attestation bundles were made for hmda_analyzer-0.3.0-py3-none-any.whl:

Publisher: release.yml on Jaypatel1511/hmda-analyzer

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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