junaid008 commited on
Commit
e5e2a79
·
verified ·
1 Parent(s): da0e79d

pakdata 0.1.0: pak_cities

Browse files
Files changed (2) hide show
  1. README.md +176 -0
  2. data/train.parquet +3 -0
README.md ADDED
@@ -0,0 +1,176 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: cc-by-4.0
3
+ pretty_name: "Pakistan populated places (GeoNames): location, province, elevation, population"
4
+ language:
5
+ - en
6
+ task_categories:
7
+ - tabular-regression
8
+ tags:
9
+ - pakistan
10
+ - pakdata
11
+ - tabular
12
+ - geography
13
+ - cities
14
+ - population
15
+ - geonames
16
+ size_categories:
17
+ - n<1K
18
+ configs:
19
+ - config_name: default
20
+ data_files:
21
+ - split: train
22
+ path: data/train.parquet
23
+ ---
24
+
25
+ # Pakistan populated places (GeoNames): location, province, elevation, population
26
+
27
+ Part of **[pakdata](https://github.com/junaidaslam2006/pakData)**, a collection of real, openly licensed Pakistan-specific datasets for machine learning.
28
+ Every value comes from the named public source below; nothing is synthetic or AI-generated.
29
+
30
+ | | |
31
+ |---|---|
32
+ | Rows | 575 |
33
+ | Default target | `log_population` (regression) |
34
+ | Source | GeoNames (geonames.org daily export PK.zip + admin1CodesASCII.txt) |
35
+ | License | CC BY 4.0 |
36
+ | Snapshot | 2026.11 |
37
+
38
+ ## Load it
39
+
40
+ ```python
41
+ # Hugging Face datasets
42
+ from datasets import load_dataset
43
+ ds = load_dataset("junaid008/pak_cities", split="train")
44
+ df = ds.to_pandas()
45
+
46
+ # pandas only
47
+ import pandas as pd
48
+ df = pd.read_parquet("hf://datasets/junaid008/pak_cities/data/train.parquet")
49
+
50
+ # pakdata (scikit-learn style, works offline) pip install pakdata
51
+ from pakdata import load_pak_cities
52
+ X, y = load_pak_cities(return_X_y=True)
53
+ ```
54
+
55
+ **Features used by `pakdata`:** `latitude`, `longitude`, `feature_code`, `province`, `elevation_m`, `elevation_source`
56
+
57
+ **Kept in the table but not used as features** (ids, raw dates, or columns that would leak the target): `geonameid`, `name`, `ascii_name`, `population`, `timezone`, `modification_date`, `pop_shared_with_namesake`
58
+
59
+ ## Data card
60
+
61
+ The full data card (column meanings and units, how it was built, caveats, suggested tasks):
62
+
63
+ ```text
64
+ .. _pak_cities_dataset:
65
+
66
+ Pakistan populated places (GeoNames)
67
+ ------------------------------------
68
+
69
+ **Data Set Characteristics:**
70
+
71
+ :Number of Instances: 575 populated places (one row per GeoNames feature)
72
+ :Number of Attributes: 6 features (``latitude``, ``longitude``, ``feature_code``, ``province``, ``elevation_m``, ``elevation_source``) + target; 14 columns in ``frame``
73
+ :Default target: ``log_population`` (log10 of persons)
74
+ :Time coverage: static gazetteer snapshot; records last modified between 2011-02-08 and 2026-11-27; population figures are of mixed, mostly undated vintage
75
+ :Geographic coverage: Pakistan (all 4 provinces, Islamabad Capital Territory, Gilgit-Baltistan, Azad Kashmir); latitude 24.1-36.5 N, longitude 61.6-76.2 E
76
+ :Source: GeoNames geographical database, daily export https://download.geonames.org/export/dump/PK.zip and https://download.geonames.org/export/dump/admin1CodesASCII.txt (https://www.geonames.org)
77
+ :License: Creative Commons Attribution 4.0 (CC BY 4.0), https://creativecommons.org/licenses/by/4.0/ , as stated in https://download.geonames.org/export/dump/readme.txt and https://www.geonames.org/about.html
78
+ :Snapshot: 2026.11 (retrieved 2026-11-29)
79
+
80
+ **Columns:**
81
+
82
+ - ``geonameid`` (int): GeoNames feature id (identifier; excluded from features)
83
+ - ``name`` (str): place name as in GeoNames, UTF-8 (excluded from features)
84
+ - ``ascii_name`` (str): plain-ASCII name (excluded from features)
85
+ - ``latitude`` (degrees, WGS84): latitude of the place point
86
+ - ``longitude`` (degrees, WGS84): longitude of the place point
87
+ - ``feature_code`` (category): GeoNames populated-place code. Counts in this file:
88
+ PPL populated place 456, PPLA2 seat of 2nd-order admin division (district) 91,
89
+ PPLA seat of 1st-order division (provincial capital) 6, PPLX section of populated place 6,
90
+ PPLL locality 4, PPLF farm village 3, PPLA3 2, PPLW destroyed place 2,
91
+ PPLQ abandoned place 2, PPLC capital (Islamabad) 1, PPLA4 1, PPLS populated places 1
92
+ - ``province`` (category): province / territory mapped from the GeoNames admin1 code
93
+ (PK.02 Balochistan, PK.03 Khyber Pakhtunkhwa, PK.04 Punjab, PK.05 Sindh,
94
+ PK.06 Azad Kashmir, PK.07 Gilgit-Baltistan, PK.08 Islamabad, renamed here to
95
+ "Islamabad Capital Territory"). Counts: Punjab 285, Sindh 134, Khyber Pakhtunkhwa 77,
96
+ Balochistan 49, Azad Kashmir 20, Gilgit-Baltistan 7, Islamabad Capital Territory 3
97
+ - ``population`` (persons): population as recorded in GeoNames (raw; excluded from
98
+ features because it determines the target)
99
+ - ``log_population`` (log10 persons): ``log10(population)``, the default target (also
100
+ listed in ``exclude_from_features``, so it is never a feature when another
101
+ population column is chosen as target)
102
+ - ``elevation_m`` (m): GeoNames ``elevation`` field when filled (32 rows), otherwise the
103
+ GeoNames ``dem`` field (543 rows; SRTM3 ~90 m or GTOPO30 ~900 m average terrain height
104
+ around the point)
105
+ - ``elevation_source`` (category): ``elevation`` or ``dem``, which GeoNames field ``elevation_m`` came from
106
+ - ``timezone`` (str): IANA timezone; ``Asia/Karachi`` for every row (excluded from features as constant)
107
+ - ``modification_date`` (date): date the GeoNames record was last modified (excluded from features)
108
+ - ``pop_shared_with_namesake`` (bool): True when another row with the same ``ascii_name``
109
+ has exactly the same ``population`` (8 rows, 4 pairs; see caveats). Computed by pakdata
110
+ from the source values; it is derived from ``population`` and is excluded from features
111
+
112
+ **How it was built:** ``scripts/build_pak_cities.py`` downloads PK.zip (all ~230,000
113
+ GeoNames features for Pakistan) and admin1CodesASCII.txt, keeps rows with feature class
114
+ ``P`` (populated places) and population > 0, maps the admin1 code to the province name,
115
+ computes ``log_population = log10(population)``, builds ``elevation_m`` from ``elevation``
116
+ falling back to ``dem`` (DEM value -9999 would be treated as missing; none occurred),
117
+ flags ``pop_shared_with_namesake``, rounds coordinates to 5 decimals and sorts rows by
118
+ ``geonameid``. No values were imputed;
119
+ in this snapshot no column has missing values.
120
+
121
+ **Caveats and known biases:**
122
+
123
+ - GeoNames populations are NOT the 2023 Pakistan census (nor any single census). They come
124
+ from many contributors and sources of uneven vintage and accuracy; some are city-proper,
125
+ some metropolitan, some rounded estimates (e.g. Malir Cantonment 300000), and a few very
126
+ small values (4-14 persons) are user-added entries such as havelis or farmsteads.
127
+ Use them for ML practice, not for demographic statements.
128
+ - Strong selection bias: only 575 of about 150,000 populated places (feature class P;
129
+ 150,406 of the 229,987 features in this PK.txt snapshot) have a population filled in. Larger towns and district seats
130
+ are heavily over-represented, so the data is not a random sample of settlements.
131
+ - Some population figures appear to be copied between different, same-named places in
132
+ GeoNames, so a few rows are wrong at the source (pakdata keeps the source values
133
+ unchanged). Pairs in this snapshot: Sahiwal 1166548 (PPLA2, district city, 30.67 N)
134
+ and Sahiwal 1166547 (small town in Sargodha district, 31.97 N) both carry 538344;
135
+ Bahawalnagar 1183883 (PPLA2) and 1332083 (PPL, 30.55 N) both carry 241873;
136
+ Talagang 1164069 and 1335232 (33.07 N 71.93 E) both carry 79431; Noorabad 1453226
137
+ (Khyber Pakhtunkhwa) and 11027195 (Sindh) both carry 1100. These rows are marked by
138
+ ``pop_shared_with_namesake``; consider dropping them, or at least the smaller
139
+ non-seat member of each pair, e.g.
140
+ ``df = df[~df.pop_shared_with_namesake]``. Some other figures describe a tehsil or
141
+ metropolitan area rather than the town itself (e.g. Chunian 634236).
142
+ - Coverage is very uneven by region (Punjab 285 rows vs Gilgit-Baltistan 7, ICT 3).
143
+ - ``elevation_source == "elevation"`` rows are mostly recently hand-added small places, so
144
+ that column partly encodes "who entered the record" rather than geography.
145
+ - Includes a few sections of cities (PPLX, e.g. Wah Cantt, Malir Cantonment) and destroyed
146
+ or abandoned places (PPLW, PPLQ) whose population figures may be historical. Places can
147
+ overlap (a PPLX section inside a city is counted separately from that city).
148
+ - Coordinates are single points (often the town centre); DEM elevation is an area average.
149
+ - GeoNames is a crowd-edited wiki; rerunning the build script later may give different rows.
150
+
151
+ **Suggested tasks:**
152
+
153
+ 1. Regression: predict ``log_population`` from location, elevation, province and
154
+ ``feature_code``; compare LinearRegression with a RandomForest (5-fold CV R^2 is about
155
+ 0.26 and 0.31 respectively in this snapshot, so the task is hard and not leaked).
156
+ 2. Classification: ``load_pak_cities(target="province")`` and predict the province from
157
+ coordinates (plus elevation); a RandomForest reaches roughly 0.94 accuracy vs a 0.50
158
+ majority baseline. Visualise the decision boundaries on a lat/long plot.
159
+ 3. Clustering: run k-means or DBSCAN on ``latitude``/``longitude`` (optionally weighted by
160
+ population) and compare clusters with provinces.
161
+ 4. Exploration: plot rank vs population on log-log axes to check Zipf's law for Pakistani
162
+ cities, and discuss how the selection bias above affects the result.
163
+
164
+ **Citation / attribution:** GeoNames geographical database (https://www.geonames.org),
165
+ Pakistan export PK.zip and admin1CodesASCII.txt, retrieved 2026-11-29. Licensed under the
166
+ Creative Commons Attribution 4.0 License (https://creativecommons.org/licenses/by/4.0/).
167
+ Data provided "as is" without warranty or any representation of accuracy, timeliness or
168
+ completeness. Modified by pakdata: filtered to populated places with population > 0,
169
+ province names mapped from admin1 codes, log10 population and merged elevation column added.
170
+ ```
171
+
172
+ ## Citation and attribution
173
+
174
+ GeoNames geographical database (https://www.geonames.org), Pakistan export PK.zip and admin1CodesASCII.txt, retrieved 2026-11-29. Licensed under the Creative Commons Attribution 4.0 License (https://creativecommons.org/licenses/by/4.0/). Data provided "as is" without warranty or any representation of accuracy, timeliness or completeness. Modified by pakdata: filtered to populated places with population > 0, province names mapped from admin1 codes, log10 population and merged elevation column added.
175
+
176
+ Packaged by pakdata (https://github.com/junaidaslam2006/pakData). Build script: [`scripts/build_pak_cities.py`](https://github.com/junaidaslam2006/pakData/blob/main/scripts/build_pak_cities.py).
data/train.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8f0533d50100cc3cc84e4772efe61644790e191cea8e836b36c51637b6e3e924
3
+ size 47673