audiala commited on
Commit
e033fb7
·
verified ·
1 Parent(s): a39e858

Refresh: 33,289 places + search_impressions_decile ML target; fix viewer config path

Browse files

Rebuilt from the current catalog (GitHub audiala/open-data 4a652d5). Adds search_impressions_decile (Google Web impressions decile, 2026-07-03..2026-09-25). Config path now data/audiala-places.csv so the dataset viewer works.

README.md CHANGED
@@ -20,22 +20,28 @@ tags:
20
  - wikidata
21
  - multilingual
22
  - geospatial
 
 
 
 
 
23
  size_categories:
24
  - 10K<n<100K
25
  configs:
26
  - config_name: default
27
  data_files:
28
  - split: train
29
- path: audiala-places.csv
30
  ---
31
 
32
  # Audiala Places — Curated Multilingual Travel POIs
33
 
34
- 33,148 travel points of interest across 93 countries, each with a Wikidata
35
  QID, WGS84 coordinates, names in 11 languages, a type/category slug, fame
36
- signals (Wikidata PageRank + sitelink count), and a link to a published
37
- travel guide on [audiala.com](https://audiala.com) in each of the 11
38
- languages.
 
39
 
40
  **The curation filter is editorial:** a place is included if and only if
41
  Audiala has published a full travel guide for it. This dataset is
@@ -60,9 +66,26 @@ One row per Wikidata entity. Provided as CSV (flat columns) and GeoJSON
60
  | `wikidata_pagerank` | float | Wikidata PageRank (danker all-wiki run); empty for ~17 % of rows |
61
  | `sitelinks` | int | Count of Wikimedia project pages linked to the entity |
62
  | `url_en` … `url_ru` | string | Canonical audiala.com guide URL per language (native-script paths for hi/zh/ja/ru) |
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
63
 
64
  ## Intended uses
65
 
 
66
  - Ranking / recommending travel destinations (fame signals included).
67
  - Multilingual POI name lookup keyed by Wikidata QID.
68
  - Map layers of curated (guide-backed) attractions.
@@ -71,14 +94,16 @@ One row per Wikidata entity. Provided as CSV (flat columns) and GeoJSON
71
  ## Limitations
72
 
73
  - **Not exhaustive.** Coverage = Audiala's published-guide catalog; skewed
74
- toward the US, Western Europe, and India, clustered around ~1,200 cities.
75
  Absence means "no guide yet", not "not notable".
76
  - **Category is best-effort** (~87 % Wikidata-typed, rest heuristic;
77
  `building` and `attraction` are weak classes).
78
- - A **small long tail of QID mis-mappings** may remain (188 detectable ones
79
  were removed at build time). Reports welcome.
80
- - Guide URLs were 99.7 % live (HTTP 200) on a 330-URL random sample at
81
- build time; retired pages return 410.
 
 
82
  - Fame signals are snapshots and drift as Wikidata evolves.
83
 
84
  ## License and attribution
 
20
  - wikidata
21
  - multilingual
22
  - geospatial
23
+ - tabular
24
+ - benchmark
25
+ task_categories:
26
+ - tabular-classification
27
+ - tabular-regression
28
  size_categories:
29
  - 10K<n<100K
30
  configs:
31
  - config_name: default
32
  data_files:
33
  - split: train
34
+ path: data/audiala-places.csv
35
  ---
36
 
37
  # Audiala Places — Curated Multilingual Travel POIs
38
 
39
+ 33,289 travel points of interest across 93 countries, each with a Wikidata
40
  QID, WGS84 coordinates, names in 11 languages, a type/category slug, fame
41
+ signals (Wikidata PageRank + sitelink count), a link to a published travel
42
+ guide on [audiala.com](https://audiala.com) in each of the 11 languages, and
43
+ an ML target: `search_impressions_decile`, how visible each place's guides
44
+ are in Google Search.
45
 
46
  **The curation filter is editorial:** a place is included if and only if
47
  Audiala has published a full travel guide for it. This dataset is
 
66
  | `wikidata_pagerank` | float | Wikidata PageRank (danker all-wiki run); empty for ~17 % of rows |
67
  | `sitelinks` | int | Count of Wikimedia project pages linked to the entity |
68
  | `url_en` … `url_ru` | string | Canonical audiala.com guide URL per language (native-script paths for hi/zh/ja/ru) |
69
+ | `search_impressions_decile` | int | **ML target.** Google Web impressions of the place's guide pages (11 languages summed, 2026-07-03 → 2026-09-25) as a relative decile: `0` = none (177 rows), `1` lowest … `10` highest (~3,311 rows each) |
70
+
71
+ ## ML task: predict search visibility
72
+
73
+ Given open facts about a travel place, predict how often its guide pages
74
+ appear in Google Search. The target mixes real search demand with how well
75
+ Audiala's pages rank, so it measures search visibility, not a place's global
76
+ popularity. It is ordinal: use Spearman or quadratic weighted kappa, and hold
77
+ out whole cities or countries to test generalization.
78
+
79
+ **Baseline** (gradient-boosted trees on sitelinks, PageRank, category,
80
+ country, coordinates, article tier and number of language URLs; 5-fold CV):
81
+ Spearman **0.49**, exact decile **13.6 %** (chance ≈ 9 %), within ±1
82
+ **40.6 %**. Sitelinks alone reach Spearman 0.45. The multilingual names and
83
+ geography are largely untapped. Raw impressions, clicks, CTR and positions
84
+ are not published.
85
 
86
  ## Intended uses
87
 
88
+ - Tabular ML benchmark: predict `search_impressions_decile` from open features.
89
  - Ranking / recommending travel destinations (fame signals included).
90
  - Multilingual POI name lookup keyed by Wikidata QID.
91
  - Map layers of curated (guide-backed) attractions.
 
94
  ## Limitations
95
 
96
  - **Not exhaustive.** Coverage = Audiala's published-guide catalog; skewed
97
+ toward the US, Western Europe, and India, clustered around ~1,360 cities.
98
  Absence means "no guide yet", not "not notable".
99
  - **Category is best-effort** (~87 % Wikidata-typed, rest heuristic;
100
  `building` and `attraction` are weak classes).
101
+ - A **small long tail of QID mis-mappings** may remain (207 detectable ones
102
  were removed at build time). Reports welcome.
103
+ - Guide URLs were 100 % live (HTTP 200) on a 300-URL random sample at
104
+ build time (2026-09-28); retired pages return 410.
105
+ - The search target covers one summer window (2026-07-03 → 2026-09-25), so
106
+ seasonal places are skewed.
107
  - Fame signals are snapshots and drift as Wikidata evolves.
108
 
109
  ## License and attribution
build/add_search_target.py ADDED
@@ -0,0 +1,117 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """Add the `search_impressions_decile` ML target to the Audiala Places dataset.
3
+
4
+ The target answers one question per place: how often did its audiala.com
5
+ guide pages appear in Google Web search results (impressions), relative to
6
+ every other place in the dataset? It is derived from Audiala's private Google Search Console bulk
7
+ export and published only as a relative decile, never as raw volumes.
8
+
9
+ Definition
10
+ ----------
11
+ - Window: a fixed date range of Google Search Console *Web* impressions
12
+ (the range is recorded in the README and in `--window-label`).
13
+ - Per place: impressions summed over all of its `url_<lang>` pages, after
14
+ folding `#fragment` URLs and slug redirects into the canonical page (the
15
+ same canonicalization as audiala-hugo/scripts/ctr_deficit_panel.py).
16
+ - `search_impressions_decile`: 0 when the place had no impressions in the window;
17
+ otherwise 1 (lowest) to 10 (highest), by rank among places with at least
18
+ one impression. Ties are broken by rank order, so deciles are equal-sized.
19
+
20
+ Clicks, CTR and ranking position are deliberately not published.
21
+
22
+ Input GSC JSON: {"<lang>/<country>/<city>/<place>": {"impressions": int, ...}}
23
+ as produced by `fetch_bq_pages` + `canonicalize_pages` in the SEO panel script.
24
+
25
+ Usage:
26
+ python3 build/add_search_target.py --gsc-json PATH --window-label 2026-07-03..2026-09-25
27
+ """
28
+ import argparse
29
+ import csv
30
+ import json
31
+ import unicodedata
32
+ from pathlib import Path
33
+ from urllib.parse import unquote
34
+
35
+ HERE = Path(__file__).resolve().parent
36
+ REPO_ROOT = HERE.parent
37
+ LANGUAGES = ["en", "fr", "de", "es", "pt", "it", "hi", "zh", "cs", "ja", "ru"]
38
+ SITE_BASE = "https://audiala.com/"
39
+ TARGET = "search_impressions_decile"
40
+ LEGACY_TARGETS = {"search_demand_decile"}
41
+
42
+
43
+ def url_key(url: str) -> str:
44
+ path = url[len(SITE_BASE):] if url.startswith(SITE_BASE) else url
45
+ return unicodedata.normalize("NFC", unquote(path)).strip("/")
46
+
47
+
48
+ def gsc_key(path: str) -> str:
49
+ return unicodedata.normalize("NFC", unquote(path)).strip("/")
50
+
51
+
52
+ def deciles(values: dict[str, int]) -> dict[str, int]:
53
+ """0 for zero impressions; 1..10 equal-sized rank buckets among the rest."""
54
+ out = {k: 0 for k, v in values.items() if v <= 0}
55
+ ranked = sorted((k for k, v in values.items() if v > 0), key=lambda k: values[k])
56
+ n = len(ranked)
57
+ for i, k in enumerate(ranked):
58
+ out[k] = min(10, i * 10 // n + 1)
59
+ return out
60
+
61
+
62
+ def main():
63
+ ap = argparse.ArgumentParser(description=__doc__.split("\n")[0])
64
+ ap.add_argument("--gsc-json", required=True)
65
+ ap.add_argument("--window-label", required=True)
66
+ ap.add_argument("--data-dir", default=str(REPO_ROOT / "data"))
67
+ args = ap.parse_args()
68
+
69
+ data_dir = Path(args.data_dir)
70
+ gsc = {gsc_key(k): int(v.get("impressions") or 0)
71
+ for k, v in json.load(open(args.gsc_json, encoding="utf-8")).items()}
72
+
73
+ csv_path = data_dir / "audiala-places.csv"
74
+ with open(csv_path, encoding="utf-8", newline="") as f:
75
+ reader = csv.DictReader(f)
76
+ fields = [c for c in reader.fieldnames if c != TARGET and c not in LEGACY_TARGETS]
77
+ rows = list(reader)
78
+
79
+ demand = {}
80
+ matched_pages = 0
81
+ for r in rows:
82
+ total = 0
83
+ for lang in LANGUAGES:
84
+ u = r.get(f"url_{lang}")
85
+ if u:
86
+ imp = gsc.get(url_key(u), 0)
87
+ matched_pages += imp > 0
88
+ total += imp
89
+ demand[r["wikidata_id"]] = total
90
+ dec = deciles(demand)
91
+
92
+ with open(csv_path, "w", encoding="utf-8", newline="") as f:
93
+ w = csv.DictWriter(f, fieldnames=fields + [TARGET])
94
+ w.writeheader()
95
+ for r in rows:
96
+ r[TARGET] = dec[r["wikidata_id"]]
97
+ w.writerow({k: r[k] for k in fields + [TARGET]})
98
+
99
+ geo_path = data_dir / "audiala-places.geojson"
100
+ geo = json.load(open(geo_path, encoding="utf-8"))
101
+ for feat in geo["features"]:
102
+ qid = feat["properties"]["wikidata_id"]
103
+ for legacy in LEGACY_TARGETS:
104
+ feat["properties"].pop(legacy, None)
105
+ feat["properties"][TARGET] = dec.get(qid, 0)
106
+ with open(geo_path, "w", encoding="utf-8") as f:
107
+ json.dump(geo, f, ensure_ascii=False, separators=(",", ":"))
108
+
109
+ nonzero = sum(1 for v in demand.values() if v > 0)
110
+ print(f"window {args.window_label}: {len(rows)} places, {nonzero} with impressions "
111
+ f"({nonzero / len(rows):.1%}), {matched_pages} language pages matched")
112
+ counts = {d: sum(1 for v in dec.values() if v == d) for d in range(11)}
113
+ print("decile counts:", counts)
114
+
115
+
116
+ if __name__ == "__main__":
117
+ main()
build/build_dataset.py CHANGED
@@ -84,6 +84,7 @@ from pathlib import Path
84
 
85
  import psycopg2
86
  import psycopg2.extras
 
87
  import requests
88
  from anyascii import anyascii
89
 
@@ -534,6 +535,7 @@ WHERE a.language = 'en'
534
  AND NOT EXISTS (SELECT 1 FROM places p2
535
  WHERE p2.wikidata_id = a.wikidata_id
536
  AND p2.place_kind = 'non_tourism')
 
537
  """
538
 
539
  PER_LANG_SQL = """
@@ -541,6 +543,7 @@ SELECT wikidata_id, language, name, city, country
541
  FROM articles
542
  WHERE (structured_content IS NOT NULL OR report IS NOT NULL)
543
  AND wikidata_id ~ '^Q[1-9][0-9]*$'
 
544
  """
545
 
546
  TRANSLATIONS_SQL = """
@@ -550,6 +553,45 @@ WHERE wikidata_id = ANY(%s)
550
  """
551
 
552
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
553
  # ---------------------------------------------------------------------------
554
  # Main build
555
  # ---------------------------------------------------------------------------
@@ -571,17 +613,21 @@ def main():
571
 
572
  print("1/6 querying core rows (published EN articles + best place + pagerank)...")
573
  conn = connect_db()
574
- cur = conn.cursor(name="core", cursor_factory=psycopg2.extras.RealDictCursor)
575
- cur.itersize = 5000
576
- cur.execute(CORE_SQL + (f" LIMIT {int(args.limit)}" if args.limit else ""))
 
 
 
 
 
577
  core: dict[str, dict] = {}
578
  dropped_no_coords = 0
579
- for r in cur:
580
  if r["latitude"] is None or r["longitude"] is None:
581
  dropped_no_coords += 1
582
  continue
583
  core[r["wikidata_id"]] = dict(r)
584
- cur.close()
585
  print(f" {len(core)} places with coordinates ({dropped_no_coords} dropped: no coords)")
586
 
587
  qids = sorted(core, key=lambda q: int(q[1:]))
@@ -591,21 +637,18 @@ def main():
591
  cur.execute(TRANSLATIONS_SQL, (qids,))
592
  translations = {r["wikidata_id"]: r for r in cur.fetchall()}
593
  cur.close()
 
594
  print(f" {len(translations)} translation rows")
595
 
596
  print("3/6 querying per-language article rows for URL derivation...")
597
- cur = conn.cursor(name="perlang", cursor_factory=psycopg2.extras.RealDictCursor)
598
- cur.itersize = 20000
599
- cur.execute(PER_LANG_SQL)
600
  urls: dict[str, dict[str, str]] = collections.defaultdict(dict)
601
- for r in cur:
602
  qid, lang = r["wikidata_id"], r["language"]
603
  if qid not in core or lang not in LANGUAGES:
604
  continue
605
  permalink = build_permalink(lang, r["country"], r["city"], r["name"], qid)
606
  # Canonical site URLs carry NO trailing slash (trailing-slash 301s away).
607
  urls[qid][lang] = f"{SITE_BASE}/{permalink}"
608
- cur.close()
609
  conn.close()
610
  print(f" URLs computed for {len(urls)} places")
611
 
 
84
 
85
  import psycopg2
86
  import psycopg2.extras
87
+ import psycopg2.errors
88
  import requests
89
  from anyascii import anyascii
90
 
 
535
  AND NOT EXISTS (SELECT 1 FROM places p2
536
  WHERE p2.wikidata_id = a.wikidata_id
537
  AND p2.place_kind = 'non_tourism')
538
+ AND a.wikidata_id = ANY(%s)
539
  """
540
 
541
  PER_LANG_SQL = """
 
543
  FROM articles
544
  WHERE (structured_content IS NOT NULL OR report IS NOT NULL)
545
  AND wikidata_id ~ '^Q[1-9][0-9]*$'
546
+ AND wikidata_id = ANY(%s)
547
  """
548
 
549
  TRANSLATIONS_SQL = """
 
553
  """
554
 
555
 
556
+ CANDIDATES_SQL = """
557
+ SELECT DISTINCT wikidata_id
558
+ FROM articles
559
+ WHERE language = 'en'
560
+ AND (structured_content IS NOT NULL OR report IS NOT NULL)
561
+ AND wikidata_id ~ '^Q[1-9][0-9]*$'
562
+ """
563
+
564
+
565
+ def fetch_batched(conn, sql: str, qids: list[str], batch_size: int = 2000,
566
+ retries: int = 4) -> list[dict]:
567
+ """Run `sql` (which must end with a `wikidata_id = ANY(%s)` filter) in
568
+ short, independent read-only transactions.
569
+
570
+ Hot-standby replicas cancel long-running snapshots that conflict with WAL
571
+ replay ("canceling statement due to conflict with recovery"). Small
572
+ batches keep every snapshot short; a cancelled batch is retried.
573
+ """
574
+ out: list[dict] = []
575
+ for i in range(0, len(qids), batch_size):
576
+ batch = qids[i:i + batch_size]
577
+ for attempt in range(retries):
578
+ try:
579
+ cur = conn.cursor(cursor_factory=psycopg2.extras.RealDictCursor)
580
+ cur.execute(sql, (batch,))
581
+ rows = cur.fetchall()
582
+ cur.close()
583
+ conn.rollback() # end the read-only transaction
584
+ out.extend(rows)
585
+ break
586
+ except (psycopg2.errors.SerializationFailure,
587
+ psycopg2.errors.QueryCanceled):
588
+ conn.rollback()
589
+ if attempt == retries - 1:
590
+ raise
591
+ time.sleep(2 * (attempt + 1))
592
+ return out
593
+
594
+
595
  # ---------------------------------------------------------------------------
596
  # Main build
597
  # ---------------------------------------------------------------------------
 
613
 
614
  print("1/6 querying core rows (published EN articles + best place + pagerank)...")
615
  conn = connect_db()
616
+ cur = conn.cursor()
617
+ cur.execute(CANDIDATES_SQL)
618
+ candidates = sorted((r[0] for r in cur.fetchall()), key=lambda q: int(q[1:]))
619
+ cur.close()
620
+ conn.rollback()
621
+ if args.limit:
622
+ candidates = candidates[:int(args.limit)]
623
+ print(f" {len(candidates)} candidate QIDs")
624
  core: dict[str, dict] = {}
625
  dropped_no_coords = 0
626
+ for r in fetch_batched(conn, CORE_SQL, candidates):
627
  if r["latitude"] is None or r["longitude"] is None:
628
  dropped_no_coords += 1
629
  continue
630
  core[r["wikidata_id"]] = dict(r)
 
631
  print(f" {len(core)} places with coordinates ({dropped_no_coords} dropped: no coords)")
632
 
633
  qids = sorted(core, key=lambda q: int(q[1:]))
 
637
  cur.execute(TRANSLATIONS_SQL, (qids,))
638
  translations = {r["wikidata_id"]: r for r in cur.fetchall()}
639
  cur.close()
640
+ conn.rollback()
641
  print(f" {len(translations)} translation rows")
642
 
643
  print("3/6 querying per-language article rows for URL derivation...")
 
 
 
644
  urls: dict[str, dict[str, str]] = collections.defaultdict(dict)
645
+ for r in fetch_batched(conn, PER_LANG_SQL, qids):
646
  qid, lang = r["wikidata_id"], r["language"]
647
  if qid not in core or lang not in LANGUAGES:
648
  continue
649
  permalink = build_permalink(lang, r["country"], r["city"], r["name"], qid)
650
  # Canonical site URLs carry NO trailing slash (trailing-slash 301s away).
651
  urls[qid][lang] = f"{SITE_BASE}/{permalink}"
 
652
  conn.close()
653
  print(f" URLs computed for {len(urls)} places")
654
 
data/audiala-places.csv CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:55a48e5e60844fb58c6da0f811c72aa962dc3b871870e1534e26739f9f11dd84
3
- size 40487080
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e21c7e92357ea062db51445baaaef1fa45fedb24cf095b72b520199f86b2b47c
3
+ size 40673872
data/audiala-places.geojson CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:0599da91e186a9b42527eabbbc3445e2601857d24c3337b2148e0da781c8655e
3
- size 55325878
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c536ef046e2bfd751bc13d3166a81d9dd315f357e8f86f3a9eac2f68ed2086f3
3
+ size 56507429