Datasets:
Publish 6 artifacts from the accepted manifest
Browse files- reproduction/requirements.txt +10 -0
- reproduction/source.json +192 -0
- reproduction/source_io.py +129 -0
- reproduction/train.py +71 -0
- reproduction/validate.py +29 -0
- reproduction/validate.sh +10 -0
reproduction/requirements.txt
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
numpy==1.26.4
|
| 2 |
+
pandas==2.2.3
|
| 3 |
+
xgboost==3.0.2
|
| 4 |
+
scikit-learn==1.6.1
|
| 5 |
+
requests==2.32.3
|
| 6 |
+
beautifulsoup4==4.13.3
|
| 7 |
+
lxml==5.3.1
|
| 8 |
+
openpyxl==3.1.5
|
| 9 |
+
pyarrow==19.0.1
|
| 10 |
+
pypdf==5.4.0
|
reproduction/source.json
ADDED
|
@@ -0,0 +1,192 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"construction": {
|
| 3 |
+
"access_recipe": "GET the monitoring CSV and the identification CSV from the data-donnees.az.ec.gc.ca/api/file?path=... endpoints; each returns a 302 to a short-lived signed Azure blob, so use a session that follows redirects and re-request rather than caching the signed URL. Read with pandas using encoding cp1252 or latin-1, since the French header text is not UTF-8. Select columns by position or by exact header string because headers are bilingual. Parse the reporting-period field into year plus period token (values look like 2019-annuel/annual, 2019-Q3, 2025-Q4); annual rows carry month 0. Coerce the literal string Not provided to NaN. Aggregate monitoring to one row per facility-year: label = any(value > limit) over rows with limit > 0; covariates from the year-1 aggregate; join identification on the facility identifier. Optionally left-join acute-lethality failure counts and CSO discharge days on facility and year.",
|
| 4 |
+
"expected_size": "Observed file sizes: monitoring CSV 24 MiB, identification CSV 2 MiB, acute CSV 2 MiB, CSO volumes CSV 35 MiB. The monitoring file covers 2013-2025 for the roughly 2,300 regulated systems and should be on the order of 10^5 period rows. After aggregation the modelling matrix is estimated at 17,000-19,000 system-year rows for target years 2015-2024, with a positive rate plausibly around one in five (the 2018 report's suspended-solids supplementary table shows 416 of 1,977 systems above the 25 mg/L limit, and the CBOD table shows 279 of 1,977).",
|
| 5 |
+
"format": "Three comma-separated text files with bilingual slash-joined headers: identification (one row per facility), monitoring (one row per facility-period-month), acute lethality (one row per sample). No archive, no authentication.",
|
| 6 |
+
"source_examples": "Facility 1506, Gold Bar Wastewater Treatment Plant, period 2015-Q1 month 1: average CBOD 5 mg/L, CBOD limit 25, CBOD compliance -20, suspended solids 12.6, limit 25, compliance -12.4, approval state Approved. Facility 1243, Syncrude Canada Ltd, period 2015-annuel/annual: average CBOD 7.4, limit 25, compliance -17.6. The same facility in 2013-annuel/annual shows CBOD 8.4 with limit 0, confirming limits are absent before 2015. Facility 36816, Town of Hanley Lagoon, 2018-annuel/annual: single-concentration acute lethality result Fail, then Pass in 2019 and Fail again in 2020, showing within-system persistence of toxicity failures."
|
| 7 |
+
},
|
| 8 |
+
"dataset_id": "wser-effluent-exceedance",
|
| 9 |
+
"evidence": [
|
| 10 |
+
{
|
| 11 |
+
"claim": "ECCC publishes the WSER identification and monitoring record as open CSV for 2013 to 2025 under the Open Government Licence - Canada.",
|
| 12 |
+
"quote": "These files contain information about each wastewater system as reported in the Effluent Regulatory Reporting Information System (ERRIS) by the owners/operators of each wastewater system subject to the WSER for the years 2013 to 2025.",
|
| 13 |
+
"url": "https://open.canada.ca/data/en/dataset/9e11e114-ef0d-4814-8d93-24af23716489"
|
| 14 |
+
},
|
| 15 |
+
{
|
| 16 |
+
"claim": "Exceedance is defined as a positive difference between the reported average and the applicable limit.",
|
| 17 |
+
"quote": "A positive difference indicates that the wastewater system exceeded the WSER effluent quality standard for that particular averaging period.",
|
| 18 |
+
"url": "https://data-donnees.az.ec.gc.ca/api/file?path=%2Fsubstances%2Fplaninfrastruture%2Fwastewater-systems-effluent-regulations-reported-data%2FResaeu-Wser-descriptions-EN.txt"
|
| 19 |
+
},
|
| 20 |
+
{
|
| 21 |
+
"claim": "Limits are 25 mg/L for all systems except transitional-authorization holders, which carry facility-specific limits in the same columns.",
|
| 22 |
+
"quote": "The CBOD and suspended solids limits are 25 mg/L respectively for all wastewater systems except for those systems that received a transitional authorization under the WSER.",
|
| 23 |
+
"url": "https://data-donnees.az.ec.gc.ca/api/file?path=%2Fsubstances%2Fplaninfrastruture%2Fwastewater-systems-effluent-regulations-reported-data%2FResaeu-Wser-descriptions-EN.txt"
|
| 24 |
+
},
|
| 25 |
+
{
|
| 26 |
+
"claim": "No compliance limits exist for 2013 and 2014, fixing the usable target-year range from 2015.",
|
| 27 |
+
"quote": "there are no compliance limits for the 2013 and 2014 reporting years",
|
| 28 |
+
"url": "https://data-donnees.az.ec.gc.ca/api/file?path=%2Fsubstances%2Fplaninfrastruture%2Fwastewater-systems-effluent-regulations-reported-data%2FResaeu-Wser-descriptions-EN.txt"
|
| 29 |
+
},
|
| 30 |
+
{
|
| 31 |
+
"claim": "Monitoring reports are due within 45 days after each averaging period, which supports a 1 March decision instant.",
|
| 32 |
+
"quote": "must send, within 45 days after the end of the period referred to in subsection (2), to the authorization officer, for each final discharge point, a monitoring report",
|
| 33 |
+
"url": "https://laws-lois.justice.gc.ca/eng/regulations/SOR-2012-139/section-19.html"
|
| 34 |
+
},
|
| 35 |
+
{
|
| 36 |
+
"claim": "Combined-sewer-overflow reports are due by 15 February, so prior-year CSO volumes are available at the decision instant.",
|
| 37 |
+
"quote": "send to the authorization officer a combined sewer overflow report in respect of each calendar year by February 15 of the following calendar year",
|
| 38 |
+
"url": "https://laws-lois.justice.gc.ca/eng/regulations/SOR-2012-139/page-4.html"
|
| 39 |
+
},
|
| 40 |
+
{
|
| 41 |
+
"claim": "The licence grants worldwide royalty-free use including commercial redistribution, conditional on attribution.",
|
| 42 |
+
"quote": "The Information Provider grants you a worldwide, royalty-free, perpetual, non-exclusive licence to use the Information, including for commercial purposes, subject to the terms below.",
|
| 43 |
+
"url": "https://open.canada.ca/en/open-government-licence-canada"
|
| 44 |
+
},
|
| 45 |
+
{
|
| 46 |
+
"claim": "Where no specific attribution statement is supplied, the licence prescribes a fallback attribution string, which is what we will use.",
|
| 47 |
+
"quote": "Contains information licensed under the Open Government Licence \u2013 Canada.",
|
| 48 |
+
"url": "https://open.canada.ca/en/open-government-licence-canada"
|
| 49 |
+
},
|
| 50 |
+
{
|
| 51 |
+
"claim": "The regulated population is about 2,300 systems, so system-year aggregation yields roughly 19,000 candidate rows across the usable years.",
|
| 52 |
+
"quote": "By the end of 2018, 2,316 wastewater systems out of an estimated 2,407 submitted an identification report under the WSER.",
|
| 53 |
+
"url": "https://www.canada.ca/en/environment-climate-change/services/wastewater/publications/wastewater-data-reports/wastewater-system-effluent-regulations-annual-report.html"
|
| 54 |
+
},
|
| 55 |
+
{
|
| 56 |
+
"claim": "Acute lethality testing covers a smaller subset, which is why it is an optional secondary covariate rather than the label.",
|
| 57 |
+
"quote": "A total of 368 systems tested for acute lethality and 88% of these systems reported no failures.",
|
| 58 |
+
"url": "https://www.canada.ca/en/environment-climate-change/services/wastewater/publications/wastewater-data-reports/wastewater-system-effluent-regulations-annual-report.html"
|
| 59 |
+
}
|
| 60 |
+
],
|
| 61 |
+
"limitations": [
|
| 62 |
+
"Identification-report attributes (treatment types, chlorine use, hydraulic retention time, receiving-water description, coordinates) are published as a single current-vintage snapshot with no year stamp, so they can reflect upgrades that happened after the decision instant. They are used as quasi-static covariates and the build should also report a version that drops them entirely.",
|
| 63 |
+
"The label is an any-period-above-limit indicator, not ECCC's official 75-percent-of-the-time compliance determination, so it deliberately marks more system-years as positive than the regulator would.",
|
| 64 |
+
"Sampling exposure is unequal: a monthly-reporting plant has twelve chances to exceed, an annual-reporting lagoon has one. Reporting frequency and period counts are supplied as features, but the exposure effect is not removed from the label.",
|
| 65 |
+
"Repeated systems across years induce serial correlation. Chronological splits prevent future-to-past leakage but not dependence, so a one-row-per-system variant is a necessary sensitivity check.",
|
| 66 |
+
"Coverage is partial: Nunavut, the Northwest Territories, and areas north of the 54th parallel in Quebec and Newfoundland and Labrador are outside the regulations; Yukon and Quebec municipal systems arrive under equivalency agreements with missing acute-lethality and CSO fields and possibly different limit conventions.",
|
| 67 |
+
"Reporting completeness is imperfect; the 2018 report notes 26% of systems missed one or more required monitoring reports, so a missing exceedance can mean non-reporting rather than good performance. Eligibility requires at least one filed report.",
|
| 68 |
+
"Data-entry anomalies exist in the source, including at least one 2025 row where the compliance column contradicts average minus limit, which is why the label is computed from the average and limit columns directly.",
|
| 69 |
+
"Target year 2025 is excluded because its reports are still maturing in the 2026 vintage; results should not be extended to 2025 without re-checking completeness.",
|
| 70 |
+
"The Open Government Licence - Canada excludes personal information and third-party rights and is governed by Ontario and Canadian law. Facility-level coordinates and postal codes are present in the identification file and should be dropped from released features. Our CC0 dedication covers only our own labels, splits and code, and never the upstream data."
|
| 71 |
+
],
|
| 72 |
+
"reason": "Environment and Climate Change Canada publishes the full WSER reporting record as three plain CSVs (identification, monitoring, acute lethality) at stable API URLs, with a bilingual data dictionary and a separate prose description that defines exactly how exceedance is computed (reported average minus the system-specific limit). Limits are facility-specific only for the 65 transitional-authorization systems and are carried in the file, so the label needs no external join and no limit lookup. Coverage is ~2,300 systems per year from 2015 onward (no limits existed for 2013-2014), giving roughly 19,000 system-year observations spread over ten target years, enough for fixed chronological train/eval/holdout splits. Reporting deadlines are statutory (45 days after each averaging period; CSO reports by 15 February), which fixes a clean 1 March decision instant at which all prior-year effluent results are on file. Reuse is granted by the Open Government Licence - Canada (worldwide, royalty-free, commercial use permitted) with a specified attribution statement, so no public-domain theory is needed and no publisher permission is implied beyond the licence.",
|
| 73 |
+
"source": {
|
| 74 |
+
"attribution": "Contains information licensed under the Open Government Licence \u2013 Canada.",
|
| 75 |
+
"citation": "",
|
| 76 |
+
"documentation_url": "https://data-donnees.ec.gc.ca/data/substances/planinfrastruture/wastewater-systems-effluent-regulations-reported-data/",
|
| 77 |
+
"license": "Open Government Licence - Canada (version 2.0)",
|
| 78 |
+
"publisher": "Environment and Climate Change Canada (ECCC)",
|
| 79 |
+
"redistribution": true,
|
| 80 |
+
"terms_excerpt": "The Information Provider grants you a worldwide, royalty-free, perpetual, non-exclusive licence to use the Information, including for commercial purposes, subject to the terms below.",
|
| 81 |
+
"terms_url": "https://open.canada.ca/en/open-government-licence-canada",
|
| 82 |
+
"urls": [
|
| 83 |
+
"https://data-donnees.az.ec.gc.ca/api/file?path=%2Fsubstances%2Fplaninfrastruture%2Fwastewater-systems-effluent-regulations-reported-data%2FResaeu-Wser-surveillance-monitoring.csv",
|
| 84 |
+
"https://data-donnees.az.ec.gc.ca/api/file?path=%2Fsubstances%2Fplaninfrastruture%2Fwastewater-systems-effluent-regulations-reported-data%2FResaeu-Wser-identification.csv"
|
| 85 |
+
]
|
| 86 |
+
},
|
| 87 |
+
"task": {
|
| 88 |
+
"decision_user": "ECCC regional compliance and enforcement staff who allocate inspection and follow-up effort across roughly 2,300 regulated systems, and municipal utility managers who sequence capital upgrades and operational fixes for the coming year.",
|
| 89 |
+
"features": [
|
| 90 |
+
{
|
| 91 |
+
"availability": "Y-1 rows with a positive limit and a reported average, restricted to 2015 and later; missing when no evaluable prior-year limit row",
|
| 92 |
+
"evidence_url": "https://data-donnees.az.ec.gc.ca/api/file?path=%2Fsubstances%2Fplaninfrastruture%2Fwastewater-systems-effluent-regulations-reported-data%2FResaeu-Wser-descriptions-EN.txt",
|
| 93 |
+
"meaning": "1 if any Y-1 monitoring row with a positive applicable limit and a reported average has average strictly above limit; 0 if Y-1 has an evaluable positive-limit row and none exceed; missing if Y-1 has no evaluable positive-limit row. Limit-based history is restricted to 2015 and later, so 2015 targets are missing even if stray pre-2015 rows carry positive limits.",
|
| 94 |
+
"name": "prior_year_exceedance"
|
| 95 |
+
},
|
| 96 |
+
{
|
| 97 |
+
"availability": "Y-1 evaluable rows, restricted to 2015 and later; missing when no evaluable prior-year limit row",
|
| 98 |
+
"evidence_url": "https://data-donnees.az.ec.gc.ca/api/file?path=%2Fsubstances%2Fplaninfrastruture%2Fwastewater-systems-effluent-regulations-reported-data%2FResaeu-Wser-descriptions-EN.txt",
|
| 99 |
+
"meaning": "Maximum over Y-1 CBOD and suspended-solids evaluable rows of average minus limit, floored at 0; missing when no evaluable Y-1 limit row. Limit-based history is restricted to 2015 and later.",
|
| 100 |
+
"name": "prior_year_worst_margin"
|
| 101 |
+
},
|
| 102 |
+
{
|
| 103 |
+
"availability": "All years before Y with evaluable limit rows, restricted to 2015 and later; missing when no prior evaluable year",
|
| 104 |
+
"evidence_url": "https://data-donnees.az.ec.gc.ca/api/file?path=%2Fsubstances%2Fplaninfrastruture%2Fwastewater-systems-effluent-regulations-reported-data%2FResaeu-Wser-surveillance-monitoring.csv",
|
| 105 |
+
"meaning": "1 if any year before Y has an evaluable exceedance; 0 if at least one prior evaluable year and none; missing if no prior evaluable year. Limit-based history is restricted to 2015 and later.",
|
| 106 |
+
"name": "ever_exceeded_before"
|
| 107 |
+
},
|
| 108 |
+
{
|
| 109 |
+
"availability": "All years before Y with at least one monitoring row",
|
| 110 |
+
"evidence_url": "https://data-donnees.az.ec.gc.ca/api/file?path=%2Fsubstances%2Fplaninfrastruture%2Fwastewater-systems-effluent-regulations-reported-data%2FResaeu-Wser-surveillance-monitoring.csv",
|
| 111 |
+
"meaning": "Count of distinct calendar years before Y with at least one monitoring row.",
|
| 112 |
+
"name": "history_years_reported"
|
| 113 |
+
},
|
| 114 |
+
{
|
| 115 |
+
"availability": "Y-1 monitoring records; zero when no Y-1 record",
|
| 116 |
+
"evidence_url": "https://data-donnees.az.ec.gc.ca/api/file?path=%2Fsubstances%2Fplaninfrastruture%2Fwastewater-systems-effluent-regulations-reported-data%2FResaeu-Wser-descriptions-EN.txt",
|
| 117 |
+
"meaning": "Count of distinct year-period-month monitoring records in Y-1, a measure of sampling exposure; 0 if no Y-1 monitoring row.",
|
| 118 |
+
"name": "periods_reported_prior_year"
|
| 119 |
+
},
|
| 120 |
+
{
|
| 121 |
+
"availability": "Latest Y-1 monitoring row; inferred from period tokens when blank",
|
| 122 |
+
"evidence_url": "https://data-donnees.az.ec.gc.ca/api/file?path=%2Fsubstances%2Fplaninfrastruture%2Fwastewater-systems-effluent-regulations-reported-data%2FResaeu-Wser-descriptions-EN.txt",
|
| 123 |
+
"meaning": "Canonical annual, quarterly or monthly reporting frequency from the latest Y-1 monitoring row; inferred from period tokens if the field is blank.",
|
| 124 |
+
"name": "reporting_frequency"
|
| 125 |
+
},
|
| 126 |
+
{
|
| 127 |
+
"availability": "Latest Y-1 monitoring row",
|
| 128 |
+
"evidence_url": "https://data-donnees.az.ec.gc.ca/api/file?path=%2Fsubstances%2Fplaninfrastruture%2Fwastewater-systems-effluent-regulations-reported-data%2FResaeu-Wser-surveillance-monitoring.csv",
|
| 129 |
+
"meaning": "Intermittent or continuous wastewater system type from the latest Y-1 monitoring row.",
|
| 130 |
+
"name": "system_type"
|
| 131 |
+
},
|
| 132 |
+
{
|
| 133 |
+
"availability": "Y-1 monitoring rows; missing when no Y-1 volume",
|
| 134 |
+
"evidence_url": "https://data-donnees.az.ec.gc.ca/api/file?path=%2Fsubstances%2Fplaninfrastruture%2Fwastewater-systems-effluent-regulations-reported-data%2FResaeu-Wser-surveillance-monitoring.csv",
|
| 135 |
+
"meaning": "Mean reported average daily effluent volume in Y-1, in cubic metres per day; missing if no Y-1 value.",
|
| 136 |
+
"name": "avg_daily_effluent_volume_m3"
|
| 137 |
+
},
|
| 138 |
+
{
|
| 139 |
+
"availability": "Latest Y-1 monitoring row",
|
| 140 |
+
"evidence_url": "https://data-donnees.az.ec.gc.ca/api/file?path=%2Fsubstances%2Fplaninfrastruture%2Fwastewater-systems-effluent-regulations-reported-data%2FResaeu-Wser-surveillance-monitoring.csv",
|
| 141 |
+
"meaning": "Owner type and operator type from the latest Y-1 row, joined by a separator; missing if neither is reported.",
|
| 142 |
+
"name": "owner_type_operator_type"
|
| 143 |
+
},
|
| 144 |
+
{
|
| 145 |
+
"availability": "Latest Y-1 monitoring row, fallback to identification snapshot",
|
| 146 |
+
"evidence_url": "https://data-donnees.az.ec.gc.ca/api/file?path=%2Fsubstances%2Fplaninfrastruture%2Fwastewater-systems-effluent-regulations-reported-data%2FResaeu-Wser-surveillance-monitoring.csv",
|
| 147 |
+
"meaning": "Province from the latest Y-1 monitoring row, falling back to the identification snapshot.",
|
| 148 |
+
"name": "province"
|
| 149 |
+
},
|
| 150 |
+
{
|
| 151 |
+
"availability": "Current-vintage identification snapshot with no reporting-year stamp; treated as quasi-static",
|
| 152 |
+
"evidence_url": "https://data-donnees.az.ec.gc.ca/api/file?path=%2Fsubstances%2Fplaninfrastruture%2Fwastewater-systems-effluent-regulations-reported-data%2FResaeu-Wser-identification.csv",
|
| 153 |
+
"meaning": "Mechanical or activated-sludge class, lagoon class, no treatment, or other, parsed from the identification treatment-type list.",
|
| 154 |
+
"name": "treatment_family"
|
| 155 |
+
},
|
| 156 |
+
{
|
| 157 |
+
"availability": "Current-vintage identification snapshot; not year-versioned",
|
| 158 |
+
"evidence_url": "https://data-donnees.az.ec.gc.ca/api/file?path=%2Fsubstances%2Fplaninfrastruture%2Fwastewater-systems-effluent-regulations-reported-data%2FResaeu-Wser-identification.csv",
|
| 159 |
+
"meaning": "1 if reported hydraulic retention time is five days or more, else 0; missing if not reported.",
|
| 160 |
+
"name": "hydraulic_retention_ge_5_days"
|
| 161 |
+
},
|
| 162 |
+
{
|
| 163 |
+
"availability": "Current-vintage identification snapshot; not year-versioned",
|
| 164 |
+
"evidence_url": "https://data-donnees.az.ec.gc.ca/api/file?path=%2Fsubstances%2Fplaninfrastruture%2Fwastewater-systems-effluent-regulations-reported-data%2FResaeu-Wser-identification.csv",
|
| 165 |
+
"meaning": "1 if chlorine or a chlorine compound is reported in use, else 0; missing if not reported.",
|
| 166 |
+
"name": "chlorine_use"
|
| 167 |
+
},
|
| 168 |
+
{
|
| 169 |
+
"availability": "Current-vintage identification snapshot; not year-versioned; parsed from the water-frequented-by-fish description or name, not the generic discharge-place description",
|
| 170 |
+
"evidence_url": "https://data-donnees.az.ec.gc.ca/api/file?path=%2Fsubstances%2Fplaninfrastruture%2Fwastewater-systems-effluent-regulations-reported-data%2FResaeu-Wser-identification.csv",
|
| 171 |
+
"meaning": "Reported description or name of the water frequented by fish at the discharge point, such as a watercourse, lake or fish spawning area, taken from the water-frequented-by-fish identification column; not the generic discharge-place description.",
|
| 172 |
+
"name": "receiving_water_type"
|
| 173 |
+
},
|
| 174 |
+
{
|
| 175 |
+
"availability": "Acute-lethality CSV rows for Y-1; missing when no acute test row exists",
|
| 176 |
+
"evidence_url": "https://data-donnees.az.ec.gc.ca/api/file?path=%2Fsubstances%2Fplaninfrastruture%2Fwastewater-systems-effluent-regulations-reported-data%2FResaeu-Wser-aigue-acute.csv",
|
| 177 |
+
"meaning": "Count of failed rainbow-trout acute lethality tests in Y-1; missing when no acute test row exists, which is expected for systems below the testing threshold.",
|
| 178 |
+
"name": "prior_year_acute_lethality_failures"
|
| 179 |
+
}
|
| 180 |
+
],
|
| 181 |
+
"outcome_horizon": "The full calendar year Y (1 January to 31 December), observable from reports due by 14 February of Y+1.",
|
| 182 |
+
"population": "Wastewater systems filing at least one monitoring report in target year Y in which a CBOD or suspended-solids limit greater than 0 is recorded, with at least one prior year of monitoring history. The system-year must also have at least one such positive-limit row with a reported average; system-years with a positive limit but a missing average and no observed exceedance are excluded rather than labeled 0. No current-vintage operational-status snapshot is used to exclude historical system-years because the identification status field has no reporting-year stamp and is not year-versioned. Because no limits existed before 1 January 2015, target years run 2015 to 2024. Systems outside the regulations (Nunavut, Northwest Territories, north of the 54th parallel in Quebec and Newfoundland and Labrador) never appear. Quebec municipal systems appear under the equivalency agreement with provincial limit conventions carried in the limit columns. Eligibility and labels use year-Y reports, so this is a retrospective research cohort, not a deployable 1 March forecast roster.",
|
| 183 |
+
"prediction_time": "1 March of target year Y. Every monitoring report for a completed averaging period is due within 45 days of the period end (annual and Q4 reports therefore due by 14 February), and combined-sewer-overflow reports are due by 15 February, so all year Y-1 effluent results and CSO volumes are on file at the statutory deadline. The timing metadata treats the 45-day statutory lag as a publication proxy; actual publication dates of the downloaded current-vintage CSV are not verified. Identification-report attributes are treated as a current-vintage snapshot.",
|
| 184 |
+
"question": "At the start of a compliance year, will a federally regulated Canadian wastewater system report at least one effluent monitoring period whose average CBOD or suspended-solids concentration exceeds the limit that applies to it?",
|
| 185 |
+
"simple_references": "Persistence (predict Y from the Y-1 exceedance flag), majority class (no exceedance, roughly four in five system-years), a province-by-treatment-family base rate, and an ever-exceeded-before indicator. These establish how much of the signal is habit versus structure.",
|
| 186 |
+
"split_policy": "Fixed chronological boundaries by target year: train 2015-2019, eval 2020-2022, holdout 2023-2024. No embargo year is needed because each label window is a single non-overlapping calendar year and every feature is dated on or before 31 December Y-1, so no row can see a later row's outcome. Target year 2025 is excluded because its reports are still maturing in the current data vintage. Reporting-completeness strata and province are kept balanced across the three periods by construction of the year windows, not by resampling.",
|
| 187 |
+
"target": "For system i and target calendar year Y, label = 1 if any monitoring row for year Y with a reported CBOD limit greater than 0 has average CBOD strictly greater than that limit, or any row with a reported suspended-solids limit greater than 0 has average suspended solids strictly greater than that limit; otherwise 0. Computed from the reported average and the reported limit, not from the pre-computed compliance column. Rows for 2013 and 2014 are excluded because no limits applied.",
|
| 188 |
+
"usefulness": "Exceedance cannot be read off any field at the decision instant: it must be forecast from plant design class, retention time, disinfection practice, scale, sampling regime, jurisdiction and multi-year margin history. A regulator with about 2,300 systems and limited inspectors cannot inspect everything; knowing which compliant-looking systems are about to tip over, and which chronic lagoon systems are structurally stuck, changes where follow-up and upgrade money go. Persistence alone under-performs because first-time exceedances and post-upgrade recoveries are exactly the cases that matter operationally, and because transitional-authorization systems are judged against their own relaxed limit rather than 25 mg/L."
|
| 189 |
+
},
|
| 190 |
+
"title": "Will a Canadian wastewater system exceed its federal effluent quality limit next year? Forward exceedance prediction from WSER identification and monitoring reports",
|
| 191 |
+
"verdict": "ready"
|
| 192 |
+
}
|
reproduction/source_io.py
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Reproducible public source downloads, with bounded transport retries."""
|
| 2 |
+
import hashlib
|
| 3 |
+
import html
|
| 4 |
+
from html.parser import HTMLParser
|
| 5 |
+
import json
|
| 6 |
+
from pathlib import Path
|
| 7 |
+
import re
|
| 8 |
+
import time
|
| 9 |
+
import urllib.error
|
| 10 |
+
import urllib.parse
|
| 11 |
+
import urllib.request
|
| 12 |
+
|
| 13 |
+
MAX_BYTES = 1024 * 1024 * 1024
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
class TermsEvidenceError(ValueError):
|
| 17 |
+
pass
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
def excerpt_match(text, excerpt):
|
| 21 |
+
# Inline HTML nodes can put whitespace before punctuation during extraction.
|
| 22 |
+
# Explicit ellipses denote omissions, not invented words: every remaining
|
| 23 |
+
# verbatim span must occur in order in the preserved publisher document.
|
| 24 |
+
def normalize(value):
|
| 25 |
+
value = ' '.join(html.unescape(value).split())
|
| 26 |
+
return re.sub(r'\s+([,;:.!?])', r'\1', value)
|
| 27 |
+
text, excerpt = normalize(text), normalize(excerpt)
|
| 28 |
+
if excerpt and excerpt in text:
|
| 29 |
+
return 'contiguous'
|
| 30 |
+
spans = [span.strip() for span in re.split(r'\.{3}|…', excerpt) if span.strip()]
|
| 31 |
+
if len(spans) < 2:
|
| 32 |
+
return None
|
| 33 |
+
offset = 0
|
| 34 |
+
for span in spans:
|
| 35 |
+
found = text.find(span, offset)
|
| 36 |
+
if found < 0:
|
| 37 |
+
return None
|
| 38 |
+
offset = found + len(span)
|
| 39 |
+
return 'ordered-verbatim-spans-with-explicit-omissions'
|
| 40 |
+
|
| 41 |
+
|
| 42 |
+
def capture_terms(source, cache):
|
| 43 |
+
"""Capture publisher evidence and establish that the quoted grant is present.
|
| 44 |
+
|
| 45 |
+
Presence is mechanical; applicability/compatibility remains semantic review.
|
| 46 |
+
"""
|
| 47 |
+
try:
|
| 48 |
+
terms = fetch(source['terms_url'], cache, 'publisher-terms.snapshot')
|
| 49 |
+
documentation = fetch(source['documentation_url'], cache, 'publisher-documentation.snapshot')
|
| 50 |
+
raw = terms.read_bytes()
|
| 51 |
+
if raw.startswith(b'%PDF-'):
|
| 52 |
+
from pypdf import PdfReader
|
| 53 |
+
text = '\n'.join(page.extract_text() or '' for page in PdfReader(terms).pages)
|
| 54 |
+
else:
|
| 55 |
+
class Text(HTMLParser):
|
| 56 |
+
def __init__(self): super().__init__(); self.parts = []
|
| 57 |
+
def handle_data(self, data): self.parts.append(data)
|
| 58 |
+
parser = Text(); parser.feed(raw.decode('utf-8', errors='replace'))
|
| 59 |
+
text = ' '.join(parser.parts)
|
| 60 |
+
match = excerpt_match(text, source['terms_excerpt'])
|
| 61 |
+
if not match:
|
| 62 |
+
raise TermsEvidenceError('The claimed terms excerpt is absent from the captured publisher document')
|
| 63 |
+
return {'ok': True, 'terms_url': source['terms_url'], 'terms_sha256': sha(terms),
|
| 64 |
+
'documentation_url': source['documentation_url'], 'documentation_sha256': sha(documentation),
|
| 65 |
+
'quoted_excerpt': source['terms_excerpt'], 'excerpt_found': True, 'excerpt_match': match,
|
| 66 |
+
'scope': 'Captured publisher bytes and quote presence; semantic applicability reviewed separately'}
|
| 67 |
+
except TermsEvidenceError:
|
| 68 |
+
raise
|
| 69 |
+
except Exception as exc:
|
| 70 |
+
raise TermsEvidenceError('Publisher terms/documentation could not be captured: ' + type(exc).__name__) from exc
|
| 71 |
+
|
| 72 |
+
|
| 73 |
+
def sha(path):
|
| 74 |
+
digest = hashlib.sha256()
|
| 75 |
+
with Path(path).open('rb') as stream:
|
| 76 |
+
for block in iter(lambda: stream.read(1024 * 1024), b''):
|
| 77 |
+
digest.update(block)
|
| 78 |
+
return digest.hexdigest()
|
| 79 |
+
|
| 80 |
+
|
| 81 |
+
def fetch(url, cache, name):
|
| 82 |
+
cache = Path(cache)
|
| 83 |
+
if (urllib.parse.urlsplit(url).scheme != 'https' or not name
|
| 84 |
+
or Path(name).name != name or name in ('.', '..', 'sources.json')):
|
| 85 |
+
raise ValueError('Use an HTTPS source and a plain cache filename')
|
| 86 |
+
cache.mkdir(parents=True, exist_ok=True)
|
| 87 |
+
path = cache / name
|
| 88 |
+
lock = cache / 'sources.json'
|
| 89 |
+
records = json.loads(lock.read_text()) if lock.exists() else {}
|
| 90 |
+
if path.is_symlink():
|
| 91 |
+
raise ValueError('Source cache symlink refused')
|
| 92 |
+
if name in records:
|
| 93 |
+
entry = records[name]
|
| 94 |
+
if entry['url'] != url or not path.is_file() or sha(path) != entry['sha256']:
|
| 95 |
+
raise ValueError('Cached source changed or filename reused')
|
| 96 |
+
return path
|
| 97 |
+
temporary = cache / (name + '.part')
|
| 98 |
+
if temporary.is_symlink():
|
| 99 |
+
raise ValueError('Source temporary path is a symlink')
|
| 100 |
+
for attempt in range(3):
|
| 101 |
+
try:
|
| 102 |
+
request = urllib.request.Request(url, headers={'User-Agent': 'DatasetFactory/1.0 (research; reproducible public data)'})
|
| 103 |
+
with urllib.request.urlopen(request, timeout=45) as response, temporary.open('wb') as out:
|
| 104 |
+
if urllib.parse.urlsplit(response.url).scheme != 'https':
|
| 105 |
+
raise ValueError('Source redirect downgraded HTTPS')
|
| 106 |
+
total = 0
|
| 107 |
+
for block in iter(lambda: response.read(1024 * 1024), b''):
|
| 108 |
+
total += len(block)
|
| 109 |
+
if total > MAX_BYTES:
|
| 110 |
+
raise ValueError('Source file exceeds 1 GiB bounded download')
|
| 111 |
+
out.write(block)
|
| 112 |
+
if not total:
|
| 113 |
+
raise ValueError('Source download is empty')
|
| 114 |
+
temporary.replace(path)
|
| 115 |
+
records[name] = {'url': url, 'bytes': total, 'sha256': sha(path),
|
| 116 |
+
'retrieved_at_unix': time.time(), 'transport_attempts': attempt + 1}
|
| 117 |
+
pending = cache / 'sources.json.part'
|
| 118 |
+
pending.write_text(json.dumps(records, indent=2) + '\n')
|
| 119 |
+
pending.replace(lock)
|
| 120 |
+
return path
|
| 121 |
+
except (urllib.error.URLError, TimeoutError, ConnectionError) as exc:
|
| 122 |
+
if isinstance(exc, urllib.error.HTTPError):
|
| 123 |
+
exc.close()
|
| 124 |
+
if exc.code not in (408, 429, 500, 502, 503, 504):
|
| 125 |
+
raise
|
| 126 |
+
if attempt == 2:
|
| 127 |
+
raise
|
| 128 |
+
time.sleep(2 ** attempt)
|
| 129 |
+
|
reproduction/train.py
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Baseline XGBoost binary classifier. THIS IS THE ONLY FILE THE AGENT EDITS.
|
| 2 |
+
|
| 3 |
+
Contract (see program.md):
|
| 4 |
+
1. `python train.py` trains on data/train.csv, evaluates on data/eval.csv, prints `Eval AUC: 0.xxxx`.
|
| 5 |
+
2. After running, a module-level function `predict_proba(df)` exists: raw DataFrame -> 1-D array of P(positive).
|
| 6 |
+
"""
|
| 7 |
+
import json
|
| 8 |
+
import os
|
| 9 |
+
import time
|
| 10 |
+
|
| 11 |
+
import numpy as np
|
| 12 |
+
import pandas as pd
|
| 13 |
+
import xgboost as xgb
|
| 14 |
+
from sklearn.metrics import roc_auc_score
|
| 15 |
+
|
| 16 |
+
TASK = json.load(open("task.json"))
|
| 17 |
+
TARGET = TASK["target"]
|
| 18 |
+
POSITIVE = TASK["positive_label"]
|
| 19 |
+
ID_COLS = TASK.get("id_columns", [])
|
| 20 |
+
N_JOBS = int(os.environ.get("BENCH_THREADS", "4"))
|
| 21 |
+
SEED = 42
|
| 22 |
+
|
| 23 |
+
train = pd.read_csv("data/train.csv")
|
| 24 |
+
evald = pd.read_csv("data/eval.csv")
|
| 25 |
+
|
| 26 |
+
# --- features -----------------------------------------------------------------
|
| 27 |
+
feature_cols = [c for c in train.columns if c not in ID_COLS + [TARGET]]
|
| 28 |
+
obj_cols = [c for c in feature_cols if pd.api.types.is_object_dtype(train[c]) or pd.api.types.is_string_dtype(train[c])]
|
| 29 |
+
# baseline: treat string columns as categoricals, but drop very high-cardinality ones (names, free text, timestamps)
|
| 30 |
+
cat_cols = [c for c in obj_cols if train[c].nunique() <= 1000]
|
| 31 |
+
feature_cols = [c for c in feature_cols if c not in obj_cols or c in cat_cols]
|
| 32 |
+
cat_levels = {c: pd.Index(sorted(train[c].dropna().unique())) for c in cat_cols}
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
def prepare(df: pd.DataFrame) -> pd.DataFrame:
|
| 36 |
+
# ALL feature engineering belongs here: predict_proba() calls prepare() on unseen rows, so anything you
|
| 37 |
+
# compute on `train`/`evald` outside this function will NOT be applied to the hidden holdout.
|
| 38 |
+
X = df[feature_cols].copy()
|
| 39 |
+
for c in cat_cols:
|
| 40 |
+
X[c] = pd.Categorical(X[c], categories=cat_levels[c]) # unseen levels -> NaN
|
| 41 |
+
return X
|
| 42 |
+
|
| 43 |
+
|
| 44 |
+
def to_y(df: pd.DataFrame) -> np.ndarray:
|
| 45 |
+
return (df[TARGET] == POSITIVE).astype(int).to_numpy()
|
| 46 |
+
|
| 47 |
+
|
| 48 |
+
# --- model --------------------------------------------------------------------
|
| 49 |
+
model = xgb.XGBClassifier(
|
| 50 |
+
n_estimators=30,
|
| 51 |
+
max_depth=6,
|
| 52 |
+
learning_rate=0.1,
|
| 53 |
+
tree_method="hist",
|
| 54 |
+
enable_categorical=True,
|
| 55 |
+
random_state=SEED,
|
| 56 |
+
n_jobs=N_JOBS,
|
| 57 |
+
)
|
| 58 |
+
|
| 59 |
+
t0 = time.time()
|
| 60 |
+
model.fit(prepare(train), to_y(train))
|
| 61 |
+
print(f"Training time: {time.time() - t0:.1f}s")
|
| 62 |
+
|
| 63 |
+
|
| 64 |
+
def predict_proba(df: pd.DataFrame) -> np.ndarray:
|
| 65 |
+
return model.predict_proba(prepare(df))[:, 1]
|
| 66 |
+
|
| 67 |
+
|
| 68 |
+
t0 = time.time()
|
| 69 |
+
eval_auc = roc_auc_score(to_y(evald), predict_proba(evald))
|
| 70 |
+
print(f"Eval time: {time.time() - t0:.1f}s")
|
| 71 |
+
print(f"Eval AUC: {eval_auc:.4f}")
|
reproduction/validate.py
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Check that train.py satisfies the benchmark contract, using data/eval.csv as a stand-in for the hidden holdout.
|
| 2 |
+
Usage: python validate.py (re-runs training; costs one experiment's worth of time but is NOT logged)
|
| 3 |
+
DO NOT EDIT THIS FILE.
|
| 4 |
+
"""
|
| 5 |
+
import json
|
| 6 |
+
import runpy
|
| 7 |
+
import sys
|
| 8 |
+
import time
|
| 9 |
+
|
| 10 |
+
import numpy as np
|
| 11 |
+
import pandas as pd
|
| 12 |
+
from sklearn.metrics import roc_auc_score
|
| 13 |
+
|
| 14 |
+
task = json.load(open("task.json"))
|
| 15 |
+
t0 = time.time()
|
| 16 |
+
ns = runpy.run_path("train.py", run_name="__train__")
|
| 17 |
+
print(f"[validate] train.py ran in {time.time() - t0:.1f}s")
|
| 18 |
+
fn = ns.get("predict_proba")
|
| 19 |
+
if not callable(fn):
|
| 20 |
+
sys.exit("[validate] FAIL: train.py does not define a callable predict_proba(df)")
|
| 21 |
+
df = pd.read_csv("data/eval.csv")
|
| 22 |
+
y = (df[task["target"]] == task["positive_label"]).astype(int).to_numpy()
|
| 23 |
+
p = np.asarray(fn(df.drop(columns=[task["target"]])), dtype=float).ravel()
|
| 24 |
+
if p.shape[0] != len(df):
|
| 25 |
+
sys.exit(f"[validate] FAIL: predict_proba returned {p.shape[0]} values for {len(df)} rows")
|
| 26 |
+
if not np.all(np.isfinite(p)) or p.min() < 0 or p.max() > 1:
|
| 27 |
+
sys.exit("[validate] FAIL: predict_proba must return finite probabilities in [0, 1]")
|
| 28 |
+
print(f"[validate] eval AUC via predict_proba (target column removed): {roc_auc_score(y, p):.4f}")
|
| 29 |
+
print("[validate] CONTRACT OK")
|
reproduction/validate.sh
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env bash
|
| 2 |
+
# Run the contract check with the benchmark's Python interpreter. Usage: ./validate.sh (see validate.py)
|
| 3 |
+
# DO NOT EDIT THIS FILE.
|
| 4 |
+
set -u
|
| 5 |
+
cd "$(dirname "$0")"
|
| 6 |
+
[ -f ../bench.env ] && . ../bench.env
|
| 7 |
+
[ -f .bench/env ] && . ./.bench/env
|
| 8 |
+
export BENCH_THREADS="${BENCH_THREADS:-4}" OMP_NUM_THREADS="${BENCH_THREADS:-4}"
|
| 9 |
+
export BENCH_LEDGER_EXEMPT=1 # recorded in the ledger as exempt, never refused
|
| 10 |
+
exec "${BENCH_PYTHON:-python}" validate.py
|