polymetrics
Fast object-level (polygon) accuracy metrics for geospatial ML. Compare two GeoJSONs and get precision, recall, F1, IoU, mAP, and polygon-shape statistics in one call.
uvx polymetrics truth.geojson pred.geojson
from polymetrics import evaluate
result = evaluate("truth.geojson", "pred.geojson", iou_threshold=0.5)
print(result.precision, result.recall, result.f1, result.mean_iou)
result.to_geojson("annotated.geojson")
What it computes
| Metric | Definition |
|---|---|
precision, recall, f1 |
Standard object-level scores after one-to-one Hungarian matching on IoU |
mean_iou |
Mean IoU across matched (TP) pairs |
map_50 |
Mean Average Precision at IoU=0.5, 101-point AP integration (COCO-style) |
map_50_95 |
Mean of mAP at IoU thresholds 0.5, 0.55, ..., 0.95 |
avg_vertices |
Mean exterior vertex count across predicted polygons |
orthogonality |
Mean fraction of edges within 5° of each polygon's MBR dominant axis |
How it differs from pixel metrics
Pixel IoU pools every pixel and asks "what fraction did you get right?". Object IoU asks "did you find each building, and how well-shaped is each one?" which is what users actually see on a map. Both are useful for different reasons; this library only does object-level.
CRS handling
Inputs are always reprojected to EPSG:3857 before any geometric computation. If the prediction and truth GeoJSONs declare different source CRSs, a warning is emitted and both are projected. A missing CRS is treated as EPSG:4326 (the GeoJSON 2008 default).
Matching algorithm
Hungarian bipartite assignment (scipy.optimize.linear_sum_assignment) on a -IoU cost matrix, with gdf.sindex (STRtree) pruning to skip non-overlapping pairs. Each prediction matches at most one truth; pairs below iou_threshold are dropped (the prediction becomes FP, the truth FN).
mAP
mAP requires each prediction feature to carry a score or confidence property in [0, 1]. If neither is present, mAP is reported as null and a warning is emitted; the other metrics still compute.
Install
uv pip install polymetrics
CLI
polymetrics truth.geojson pred.geojson [options]
positional arguments:
truth ground-truth GeoJSON
pred prediction GeoJSON
options:
--iou FLOAT IoU threshold for TP (default: 0.5)
--no-map skip mAP computation
--out PATH write annotated GeoJSON (TP/FP/FN per feature)
--json emit metrics as JSON on stdout
License
Apache-2.0.
Metadata
Release files for polymetrics 0.2.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| polymetrics-0.2.2.tar.gz | 11.6 kB | Without provenance | Details for polymetrics-0.2.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| polymetrics-0.2.2-py3-none-any.whl | Python 3 | none | any | Details for polymetrics-0.2.2-py3-none-any.whl |
Total release size: 22.9 kB
Release files / polymetrics-0.2.2.tar.gz
| Download URL | polymetrics-0.2.2.tar.gz |
|---|---|
| Size | 11.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4823c4de414da1861a4bbb2b128c4c011dc2e8745d6665944bd90865691457f3
|
|
BLAKE2b-256 checksum How to use checksums |
53c6c9ad7ad7169082ec0a58c4b3a0ddf74679bde1032cc9568bbf13fd91a565
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.17 {"installer":{"name":"uv","version":"0.11.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / polymetrics-0.2.2-py3-none-any.whl
| Download URL | polymetrics-0.2.2-py3-none-any.whl |
|---|---|
| Size | 11.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
24e269a2c30cdb18fa23caaeac247ab1192242ff05058d793ef5bf0b5d7b44e8
|
|
BLAKE2b-256 checksum How to use checksums |
4f23f379e81eebb5901f9849f9d98fd12a7eb20358d732f89224f82d55f19efb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.17 {"installer":{"name":"uv","version":"0.11.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for polymetrics 0.2.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.