Commit d339e88
feat(governance): add Gebru-style datasheets for training datasets (#52)
* feat(governance): add SHAP explainability for segmentation predictions (#29)
- Add governance module with SHAPExplainer class
- Implement band-level and spatial attribution using DeepExplainer
- Add /api/explain endpoint for SHAP-based explanations
- Create 06_explainability.ipynb with visualization examples
- Add shap>=0.42.0 to requirements.txt
Closes #22
Co-authored-by: Linda Oraegbunam <obielinda@gmail.com>
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
* chore: bring repo up to open-source community standards (#16)
* Add SECURITY.md for security policy and reporting
Added a security policy document outlining supported versions, vulnerability reporting, scope, and disclosure policy.
* chore: add PR template for contributor guidance
Add a pull request template to guide contributors.
* chore: add CODEOWNERS assigning @Goldokpa as default reviewer
Added CODEOWNERS file to define code ownership and review assignments.
* chore: add Dependabot config for pip, npm, and GitHub Actions
Configured Dependabot for Python, GitHub Actions, and npm dependencies with specified schedules and reviewers.
* chore: add CHANGELOG.md following Keep a Changelog format
Document notable changes, additions, modifications, and removals for ClimateVision.
* chore: add CITATION.cff to enable GitHub Cite this repository button
Added citation file for ClimateVision software.
* fix: replace #email placeholder in CODE_OF_CONDUCT with Security Advisory link
This change updates the Code of Conduct document by removing the original content and replacing it with a new version that includes various sections on community standards, enforcement responsibilities, and guidelines.
* chore: remove SETUP_COMPLETE.md (internal artifact not suited for public repo)
* chore: remove internal team_docs (Francis_Umo_Role.pdf) from public repo
* chore: remove internal team_docs (Olufemi_Taiwo_Role.pdf) from public repo
* feat(models): add biomass and carbon-stock regression module (#46)
Adds BiomassRegressor — a wrapper around sklearn RandomForest and
xgboost.XGBRegressor that exposes a stable fit/predict/evaluate/save
API for ClimateVision pipelines. Default feature ordering matches the
spectral indices produced by the data preprocessor (NDVI, EVI, SAVI,
NDMI, NBR, R, G, B, NIR, SWIR1).
Also adds:
- biomass_to_carbon / biomass_to_co2e helpers using IPCC defaults
(carbon fraction 0.47, 44/12 ratio for CO2e).
- evaluate_regression for RMSE, MAE, R^2, and MAPE.
- estimate_biomass_from_indices for inference over a dict of
per-pixel index arrays.
- save() / load() round-trip via pickle.
Co-authored-by: Francis Umo <franchaise@users.noreply.github.com>
* feat(notebooks): add 03_carbon_analysis carbon stock estimation notebook (#47)
End-to-end notebook that loads (or simulates) a biomass-labelled
spectral dataset, trains a Random Forest BiomassRegressor, evaluates
RMSE/MAE/R^2/MAPE, converts biomass predictions to carbon and CO2e
using IPCC defaults, plots feature importances, and persists the
model + metrics for the analytics API and the model-card pipeline.
Falls back to a synthetic dataset when the labelled parquet file is
not present, so the notebook is runnable in CI.
Co-authored-by: Francis Umo <franchaise@users.noreply.github.com>
* feat(notebooks): add 04_model_validation benchmarking notebook (#48)
Validates segmentation predictions against reference masks and the
biomass regressor against held-out labels across Amazon, Congo, and
Southeast Asia. Computes IoU, F1, precision, recall, accuracy, and
the regression metrics RMSE/MAE/R^2/MAPE. Aggregates per-region and
mean values into a single benchmark_report.json that the governance
CI gate and the model-card generator consume directly.
Co-authored-by: Francis Umo <franchaise@users.noreply.github.com>
* feat(notebooks): add 05_impact_reporting stakeholder template (#49)
End-to-end impact reporting workflow: loads a deforestation mask,
runs estimate_carbon for tonnes-of-CO2e and confidence intervals,
computes a trend over the trailing 12 months, attaches validation
metrics from 04_model_validation.ipynb when available, calls
analytics.reporting.generate_report, and renders a stakeholder-ready
Markdown narrative with headline numbers, trend, and validation
section. Region/period/bbox are top-level constants so the same
notebook can be re-run for Amazon, Congo, or Southeast Asia.
Co-authored-by: Francis Umo <franchaise@users.noreply.github.com>
* feat(inference): add parallel batch processor with per-job tracking (#40)
Adds BatchProcessor for running inference over a list of sources in
parallel. Tracks per-job state (queued -> running -> succeeded/failed),
records timing and attempt counts, and appends each terminal job to a
JSONL manifest as it finishes so long-running batches can be resumed
or audited without waiting on the whole queue.
Supports configurable retry on transient failures and an injectable
inference_fn for testing and for swapping in batch_predict
implementations later.
* feat(inference): add subscription-driven deforestation alert generator (#41)
AlertGenerator matches inference results against per-organisation
subscriptions (region bbox + analysis_type + threshold) and fires
alerts when the measured value crosses the threshold. Per-subscription
cooldown windows deduplicate flapping signals. Severity is classified
medium/high/critical based on how far the value is past the threshold.
Channels are pluggable: register a delivery callable per channel name
('log', 'email', 'webhook', ...) and the dispatcher will route to all
the channels each subscription opted into. Persists every fired alert
to a JSONL log for replay and audit.
* feat(api): add /api/reports and /api/anomalies admin endpoints (#42)
Adds api/admin.py — a self-contained APIRouter exposing two read-only
operational endpoints:
- GET /api/reports — data-quality KPIs (run count, error rate, mean
confidence, positive-fraction mean, alert count) over a configurable
window.
- GET /api/anomalies — list flagged anomaly/alert records, optionally
filtered by severity and time window.
Both read from the JSONL logs written by the audit logger and the
alert generator. They never expose raw input payloads. Wired into the
FastAPI app via include_router() in api/main.py.
* feat(governance): add anomaly detection for inference outputs (#35)
Hybrid detector that combines an Isolation Forest fitted on rolling
prediction history with a statistical fallback (z-score + IQR fences)
for the cold-start case. Persists feature history to JSONL and emits
anomaly reports for human review.
* feat(governance): add hash-chained audit logger for predictions (#36)
Append-only JSONL audit trail. Each entry records the model version,
SHA-256 hash of the input payload, summary statistics for the output,
and a prev_hash linking back through the chain. verify_chain() walks
the file and detects any tampered entry by recomputing the hash and
checking the link to its predecessor.
* feat(governance): add automated model card generator (#37)
Builds Mitchell-style model cards from training config + evaluation
metrics, with optional fairness report attached. Renders to both
Markdown (for release notes / model registry) and JSON (for downstream
tooling). Ships a CLI entrypoint at scripts/generate_model_card.py for
the release CI pipeline.
* feat(reports): add LLM-backed impact report generator (#38)
Composes natural-language stakeholder reports from carbon analytics,
SHAP attributions, validation metrics, and fairness flags. A
deterministic template renderer is always available so the pipeline
never blocks on a missing LLM provider; when an LLM callable is
supplied (or CLIMATEVISION_LLM_PROVIDER is configured) it smooths the
template into prose using the structured data block as ground truth.
Includes a JSON sidecar so downstream tooling can ingest the report
without re-parsing Markdown.
* feat(governance): add release CI gate for metrics, fairness, and security (#39)
scripts/governance_ci_gate.py reads evaluation metrics, an optional
fairness report, and an optional security scan, and decides whether a
release passes its governance thresholds. Exit code 1 fails the build.
Thresholds default to a sensible baseline (IoU>=0.70, F1>=0.75,
fairness score>=0.80, zero high/critical security findings) and can be
overridden via --thresholds JSON. Renders a Markdown summary suitable
for posting back to the PR.
* feat(security): API security middleware, pipeline guard, and OWASP scanner (#34)
* feat(security): add API security middleware
OWASP-aligned controls layered onto FastAPI:
- Per-API-key rate limiter (sliding window, configurable)
- Payload size and Content-Length checks
- bbox sanity validation (range, ordering, max area to block DoS-via-huge-GEE-queries)
- File upload validation by magic bytes + extension whitelist
- String input sanitisation against XSS, SQLi, template injection patterns
- Security response headers (X-Content-Type-Options, X-Frame-Options, X-XSS-Protection)
* feat(security): add inference pipeline guard for adversarial inputs
InputAnomalyDetector flags suspicious tiles before model forward pass:
- Out-of-range pixel values, NaN/Inf, suspicious uniformity
- Gradient analysis to catch noise injection or constant-image attacks
PipelineGuard wraps inference with input + output checks:
- Rejects predictions where one class dominates >99% (model failure or attack)
- Flags low mean confidence and uniform probability distributions
- Returns structured security metadata alongside predictions so the API
can surface warnings to the caller.
* test(security): add security suite and OWASP scanner script
- tests/test_security.py: unit tests for the rate limiter, payload/bbox/file
validators, sanitiser, pipeline guard input/output checks, and adversarial
detection helpers.
- scripts/security_scan.py: external scanner that hits a running API and
probes for OWASP-style misconfigurations (missing headers, unauthenticated
POSTs, bbox over-area, oversized payloads). Outputs a JSON report.
* docs(data): pipeline overview, band contract, and smoke tests (#33)
* docs(team): add Adeolu role specification
Codifies Data Pipeline & GIS Lead responsibilities: real GEE tile downloads,
analysis-specific band mapping, SCL cloud masking at inference time, and the
synthetic-fallback guardrail.
* docs(data): document data pipeline modules and band contract
Single page covering each file in the data package, the analysis-type band
contract, the SCL cloud-masking rules, and the synthetic-fallback metadata
convention. Helps new contributors avoid hardcoding band lists.
* test(data): add band mapping smoke tests
Verifies the analysis-type → band contract holds:
- Sentinel-2 13-band canonical order
- Per-analysis band counts (4/4/3 for deforestation/ice/flood)
- SCL append-without-duplicate invariant
- Band index resolution and rejection of unknown bands
- Enabled vs disabled analysis types from config.yaml
* feat(governance): add regional bias audit framework for model fairness (#30)
- Add BiasAuditor class with demographic parity, equalized odds, and predictive parity metrics
- Implement run_bias_audit() for evaluating model fairness across regions
- Add check_fairness_gate() for CI/CD integration
- Create scripts/audit_model.py CLI tool for running audits
- Add notebooks/07_bias_audit.ipynb with visualization examples
- Support Amazon, Congo, Southeast Asia, and Boreal forest regions
Closes #23
Co-authored-by: Linda Oraegbunam <obielinda@gmail.com>
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
* feat(governance): add calibration metrics for segmentation confidence
ECE, MCE, Brier score, and reliability-bin computation for binary
segmentation outputs. Threshold-driven NGO alerts depend on calibrated
confidence: a model that says 0.9 should be right 90% of the time, and
miscalibration translates directly into missed events or false alarms.
The CalibrationReport dataclass slots into the existing model card
generator and release CI gate. Pure numpy at evaluation time, no torch.
- ReliabilityBin / CalibrationReport dataclasses with JSON serialisation
- evaluate_calibration() one-shot entrypoint
- write_calibration_report() for persistence alongside model cards
- 12 tests covering perfect/overconfident calibration, edge cases,
input validation, and round-trip JSON
* feat(governance): add Gebru-style datasheets for training datasets
Companion to the Mitchell-style model card generator (#37): where a model
card describes the model, a datasheet describes the dataset that trained
it (Gebru et al., 2018, "Datasheets for Datasets"). Both artifacts now
ship with every release.
The public API mirrors model_card.py (build / render / write / generate)
so contributors only learn one pattern and the release CI pipeline calls
them in sequence.
Sections covered: motivation, composition, collection process,
preprocessing, uses (intended + inappropriate), distribution, maintenance.
A REQUIRED_QUESTIONS schema enforces the bare minimum a release datasheet
must answer.
- Datasheet dataclass with JSON serialisation
- build_datasheet() / write_datasheet() / generate() / render_markdown()
- scripts/generate_datasheet.py CLI wired the same way as the model card
CLI for the release CI pipeline
- 12 tests covering build, validation, defaults, markdown rendering,
JSON round-trip, and YAML manifest loading
* fix(governance): correct _PROJECT_ROOT parents index in datasheet.py
---------
Co-authored-by: Gold okpa <Okpagold@gmail.com>
Co-authored-by: Linda Oraegbunam <obielinda@gmail.com>
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
Co-authored-by: Francis Umo <francisumoh360@yahoo.com>
Co-authored-by: Francis Umo <franchaise@users.noreply.github.com>
Co-authored-by: Olufemi Taiwo <117665354+femi23@users.noreply.github.com>
Co-authored-by: Linda Oraegbunam <108290852+obielin@users.noreply.github.com>
Co-authored-by: Oshgig <nifemi996@gmail.com>
Co-authored-by: Hopelynconsult <Hopelynconsult@users.noreply.github.com>1 parent e6d0248 commit d339e88
4 files changed
Lines changed: 432 additions & 0 deletions
File tree
- scripts
- src/climatevision/governance
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
10 | 11 | | |
11 | 12 | | |
12 | 13 | | |
| |||
53 | 54 | | |
54 | 55 | | |
55 | 56 | | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
56 | 64 | | |
57 | 65 | | |
58 | 66 | | |
| |||
93 | 101 | | |
94 | 102 | | |
95 | 103 | | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
96 | 110 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
0 commit comments