Real Estate Comparables Finder
Finding underpriced homes in a South Florida MLS export: the cheapest quarter of active listings is compared against closed sales within 1 km, the ten most similar sales are picked by cosine similarity, and listings priced at least $120k below them are flagged as buying opportunities.
- Built for my friend Felipe Zurbaran ↗ · Real-estate domain expert
Introduction
Which of the homes on the market right now are priced well below what similar homes nearby actually sold for? This project answers that for a South Florida MLS snapshot: 435 active listings checked against 4,958 closed sales.
It automates the comparable-sales method an appraiser uses. Take the cheapest quarter of the listings, look at every sale within a kilometre, keep the ten that are most alike in age, size and construction, and compare prices. Listings at least $120k under their comparables are the shortlist. The whole pipeline runs again in your browser below: move the sliders and it re-prices every listing.
Context
An investor scanning hundreds of active listings cannot price each one by hand. A low list price alone says nothing: it may be a bargain, or simply a smaller, older home in a cheaper street.
Do what an appraiser does, automatically: for every cheap listing, find the homes sold nearby, keep the ten most similar in age, size and construction, and compare the asking price with what those homes actually sold for.
The tool was built for Felipe Zurbaran, a friend working in real estate who wanted a repeatable way to shortlist investment candidates from MLS exports instead of reading them listing by listing. Felipe set the rules a deal had to meet. The code turns those rules into parameters:
- Cheap
- List price in the bottom 25% of the active listings
- Nearby
- Comparables are closed sales within 1 km
- Alike
- Same kind of sewer, construction and water service, similar year and living area
- Worth it
- At least $120,000 below the mean sale price of the ten best comparables
Data
Three CSV exports from the MLS: one of active listings and two of closed sales, with no MLS numbers shared between the two closed-sale files. They cover Miami-Dade and Broward. Each row has the price, coordinates and the features used for matching.
- Active
- 439 listings, 435 after the sanity checks; list prices from $160,000 to $450,000
- Closed
- 5,136 sales, 4,973 with every feature present, 4,958 after the sanity checks
- Features
- Year built, living area, and three multi-valued tags: sewer, construction and water
- Location
- Latitude and longitude; distances are great-circle (haversine) kilometres
Prices arrive as "$1,234" strings and living areas with thousands separators, so both are parsed first. Closed sales missing any feature or the sale price are dropped. The original notebook stopped there. Its top "opportunities" were data-entry errors, so this version adds the checks the prototype already had:
- Prices below $10,000 removed: a $75 and a $329 listing were rents or per-square-foot figures typed into the price field.
- The $123,456 placeholder price removed from both files.
- Coordinates outside Florida removed: one listing was geocoded in Colombia.
The raw exports also hold street addresses, MLS numbers, listing remarks and agents' phone numbers and emails. None of it is published: the page receives only the eleven fields the pipeline reads, with the categories stored as codes.
Methodology
Each step narrows the problem before the next, more expensive one. The quantile cut keeps about a quarter of the listings, the 1 km radius keeps a few dozen sales per listing, and cosine similarity only ever compares those few dozen. The original deliverable was a Folium map and a styled Excel workbook. This page replaces both with the explorer below.
The first notebook looked for statistical outliers: active listings in the lowest 20% of prices, compared with the mean price of everything within a few kilometres. It plotted the price distribution with a fitted normal curve and mapped the results with Plotly.
That mean mixed condos with houses, and asking prices with sale prices. The final notebook compares only against closed sales, and only against the ones most like the listing. It also gathers the parameters into one configuration cell and adds the price-gap filter.
Every home becomes a vector. Each sewer, construction and water tag is a 0/1 column, so a home can carry several. Year built and living area are min-max scaled to the range of the closed sales. The encoders are fitted on the closed sales only, so a tag that appears only in active listings is ignored.
Cosine similarity between the listing and each sale inside the radius ranks the candidates, and the mean sale price of the top ten is the estimate. When two sales score the same, which happens often with identical units in one building, the closer one wins. This tie-break is the one change from the notebook, which left tie order to the sort.
v(h) = [ sewer tags | construction tags | water tags | year′ | sqft′ ]
one-hot (MultiLabelBinarizer) min-max scaled
C(t) = { s ∈ sold : haversine(t, s) ≤ r } candidates in the radius
K(t) = top-N of C(t) by cos(v(t), v(s)) = v(t)·v(s) / ‖v(t)‖‖v(s)‖
gap(t) = list(t) − mean{ sale(s) : s ∈ K(t) } opportunity if gap ≤ −$120kInteractive




















Listing: 1972 · 1,784 sqft · Other Construction
| # | Sold | Similarity | Distance | Year · size · construction |
|---|---|---|---|---|
| 1 | $505,000 | 0.999 | 0.61 km | 1974 · 2,340 sqft · Other Construction |
| 2 | $650,000 | 0.875 | 0.13 km | 1972 · 2,023 sqft · CBS Construction, Other Construction |
| 3 | $640,000 | 0.698 | 0.31 km | 1979 · 2,040 sqft · CBS Construction |
| 4 | $700,000 | 0.695 | 0.68 km | 1974 · 2,566 sqft · Concrete Block Construction |
| 5 | $550,000 | 0.695 | 0.51 km | 1973 · 2,118 sqft · CBS Construction |
| 6 | $400,000 | 0.695 | 0.54 km | 1975 · 1,445 sqft · CBS Construction |
| 7 | $605,000 | 0.695 | 0.88 km | 1973 · 1,656 sqft · CBS Construction |
| 8 | $539,000 | 0.695 | 0.22 km | 1971 · 2,177 sqft · Concrete Block Construction |
| 9 | $545,000 | 0.694 | 0.73 km | 1972 · 1,374 sqft · Concrete Block With Brick |
| 10 | $555,000 | 0.608 | 0.32 km | 1972 · 1,789 sqft · CBS Construction, Concrete Block Construction |
Results
- The first-quartile threshold is $384,000: 110 of the 435 active listings fall at or below it, and every one of them has between 4 and 35 closed sales within 1 km (median 18).
- 37 of the 110 are listed at least $120,000 below the mean sale price of their ten most similar comparables; the median gap among them is −$162,200 (−33.7%), the largest −$408,900.
- Sanity checks removed 19 records the original notebook let through — a $75 and a $329 list price, a $123,456 placeholder and a listing geocoded in Colombia — which had been topping the list of opportunities.
- The browser port reproduces the Python run at the default settings, and the whole pipeline re-runs in milliseconds as the parameters change.
Technical explanation
The notebook ended in two files for the client. Both were built for someone who works in spreadsheets and maps, not in Python.
- Map
- Folium HTML with a home icon per opportunity, its dashed 1 km circle, and the comparables as markers with similarity and distance in the popup
- Report
- openpyxl workbook with a Summary sheet ranked by price gap, plus one sheet per target listing its comparables; colour-coded rows, auto-fitted columns
- Config
- One cell with RADIUS_KM, QUARTILE, TOP_N and MIN_PRICE_GAP; re-run to regenerate both files
The data is small: the bundled snapshot is about 260 KB of JSON, around 60 KB compressed. At that size the browser can rerun the analysis in milliseconds, so the parameters can be sliders rather than a fixed set of precomputed cases. The port reproduces pandas' linear quantile, the haversine formula, sklearn's multi-label and min-max encoders and its cosine similarity.
A build script reruns the Python pipeline at the defaults and saves the summary. The controls panel compares the browser's result against it, so any drift between the two versions shows on the page.
Conclusion
- The data needed more care than the model. The final notebook's best "deals" were typos, and a $10k floor that the prototype already had would have caught them.
- The comparables ignore bedrooms, bathrooms, lot size and condition. Closed sales also go up to $900,000 while the export capped listings at $450,000. Both push the comparable mean up, so a gap is a reason to look closer, not a valuation.
- The original radius search is a Python loop over every sale for every target. A latitude band plus a vectorised haversine, as in the browser port, or a spatial index would scale it to a full MLS feed.
- Next steps: weight comparables by similarity and recency instead of a flat top-ten mean, add days on market, and refresh the export on a schedule.