Skip to content

fix(deletion): compare the main category, not only the match mask - #1011

Merged
brawer merged 1 commit into
mainfrom
deletion-category
Nov 21, 2026
Merged

brawer merged 1 commit into
mainfrom
deletion-category

Conversation

@brawer

@brawer brawer commented Nov 21, 2026

Copy link
Copy Markdown
Owner

Requested by Sascha · project thread

Deletion candidates now need the main category to agree, not only the match mask. The mask lumps supermarkets, pharmacies, garden centres and car repair together, so ATP's Walmart supermarkets made Walmart's pharmacies, garden centres and auto centres deletion candidates, and fuel spiders made the shops and chargers at their stations candidates.

Change

  • Shared category code. main_category, category_factor and the pair table move from matchers/contact to a new matchers/category.rs, so the matcher and deletion use the same notion of "one business, two categories". The table keeps leaving out pairs that are two features at one site, such as a fuel station and its shop, or a counter inside a supermarket. Deletion needs exactly that line too.
  • Deletion. For each brand, network or operator and country, AtpCoverage keeps the distinct main categories of the ATP features, as interned ids, next to the mask. An OSM feature is covered if the masks intersect and its category agrees (categories_agree) with one of them. A feature without a main category is judged by the mask alone, as before, and so is a brand whose ATP features have none. shop=vacant with a brand stays a candidate. Street infrastructure keeps its own finer kind.
  • Pairs table. 23 pairs from brand:wikidata matches are added after review by hand, for example shop=mobile_phone ~ shop=telecommunication (Orange, Vodafone), shop=department_store ~ shop=supermarket (Target, Walmart), amenity=fast_food ~ shop=bakery (Greggs) and amenity=cafe ~ shop=coffee (Starbucks). The file also lists 15 pairs that were rejected, with the reason: station shops, chargers, counters inside shops.
  • Script. infer_contact_category_pairs.py --evidence=brand_wikidata reads any production conflated.parquet, because those matches ignore the category.

Eval

I ran the new deletion_reason on all 178,989 candidates of the 2026-11-16 output, with the coverage rebuilt from that output's 4.3M ATP rows. The full write-up is in docs/notes/2026-11-21-deletion-candidate-categories.md.

  • 9,792 candidates removed (5.5%): 8,709 of 165,734 by Wikidata and 1,083 of 11,879 by name. The Swiss transit candidates are unchanged.
  • What goes: 3,914 station shops (shop=convenience), 2,226 chargers at fuel stations, 774 pharmacies (Walmart, Sam's Club, Wegmans), 420 shop=gas, 409 garden centres, 151 auto centres.
  • Precision check: in a sample of 3,000 removed candidates, 69.0% have an ATP feature of the same brand within 100 m. In a sample of 3,000 candidates that stay, it is 11.8%.

Not covered

  • The new pairs also reach the matcher, where contact, brand-name and address matches between them now count at CATEGORY_PAIR_FACTOR. I didn't run the eval regions for this, so the next production run will show its effect.
  • I left out amenity=post_office ~ shop=copyshop. It's one business for The UPS Store and FedEx, but in the contact review it was postal counters inside shops. So about 100 UPS Stores mapped as post offices are no longer candidates.

Tests

  • cargo fmt --check, cargo clippy --all-targets -- -D warnings, and the 528 library tests pass, including new ones for categories_agree, category coverage by Wikidata and by name, and shop=vacant.
  • pytest for scripts/ passes.
  • The integration tests couldn't run in my environment, because it has no tippecanoe. They fail at render_conflated_overview, after conflate, and CI will run them.

Generated by Claude Code

An unmatched OSM feature became a deletion candidate when ATP had
features of its brand in the country whose match mask intersected its
own. The mask is coarse, so ATP's Walmart supermarkets made Walmart's
pharmacies, garden centres and auto centres candidates, and fuel
spiders made the shops and chargers at their stations candidates.

Coverage now also keeps the main categories of the ATP features, and an
OSM feature must have an equal category or a known pair, such as
amenity=pharmacy and shop=chemist. The pairs are the contact matcher's,
moved with main_category and category_factor to matchers/category.rs.
23 pairs from brand:wikidata matches are added, reviewed by hand;
infer_contact_category_pairs.py gains --evidence=brand_wikidata to find
them in any production run.

On the 2026-11-16 output, this removes 9,792 of 178,989 candidates
(5.5%). For 69% of a sample of them, ATP has a feature of the same
brand within 100 m, against 12% for the candidates that stay. See
docs/notes/2026-11-21-deletion-candidate-categories.md.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ttfb2NGXRJv4snY4vYNEXQ
@brawer brawer self-assigned this Nov 21, 2026
@github-actions github-actions Bot added the bug Something isn't working label Nov 21, 2026
@brawer
brawer merged commit cad49f4 into main Nov 21, 2026
7 checks passed
@brawer
brawer deleted the deletion-category branch November 21, 2026 05:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants