A modular Python framework for end‑to‑end conflict forecasting: data ingestion, transformation, drift monitoring, model and ensemble management, evaluation, reconciliation, mapping, reporting, packaging, and artifact governance.
- Conceptual Overview
- High‑Level Architecture
- Core Pipeline Stages
- Managers (Orchestration Layer)
- Modules (Functional Layer)
- Data Layer & Querysets
- Evaluation & Metrics
- Reconciliation (Hierarchical Consistency)
- Reporting & Mapping
- CLI & Argument System
- Configuration & Partitioning
- Package Management
- Logging & Monitoring
- Development Workflow
- Quick Start
- FAQ
The pipeline transforms raw geo‑temporal data into validated, reconciled, and documented forecasts. Key features include:
- Deterministic data preparation (queryset + transformation replay)
- Strict naming & artifact conventions
- Partition-aware evaluation (calibration/validation/forecasting)
- Multi-model ensembling & hierarchical reconciliation
- Automated HTML reporting and spatial visualization
- Reproducible configuration merging and logging
- Optional integration with Weights & Biases (WandB) and prediction store
┌────────────────────────────────────────┐
│ ConfigurationManager │
│ (deployment + hyperparameters + meta) │
└───────────────┬────────────────────────┘
│
┌────────────────────────▼─────────────────────────┐
│ ViewsDataLoader │
│ Queryset → Raw Fetch → Drift Check → Update │
│ → Transformation Replay → Partition Slice │
└───────────────┬──────────────────────────────────┘
│ DataFrame (month_id, entity_id)
▼
┌─────────────────────────┐
│ Model / Ensemble │
│ Training / Evaluation │
│ Forecasting / Reports │
└────────────┬────────────┘
│ Predictions
▼
┌────────────────────────┐
│ ReconciliationModule │
│ (Country ↔ Priogrid) │
└────────────┬───────────┘
│ Reconciled Predictions
▼
┌───────────────────────────┐
│ Reporting & Mapping │
│ HTML, Tables, Choropleths │
└───────────────────────────┘
| Stage | Output | Key Component |
|---|---|---|
| Data Fetch | Partitioned feature/target frame | ViewsDataLoader |
| Train | Artifact (model file) | ForecastingModelManager / EnsembleManager |
| Evaluate | Metrics + eval predictions | Evaluation logic |
| Forecast | Future horizon predictions | ForecastingModelManager |
| Reconcile | Grid ↔ country consistency | ReconciliationModule |
| Report | HTML summaries | ReportModule + MappingModule |
| Package | Poetry-compliant project | PackageManager |
| Manager | Purpose |
|---|---|
| ModelPathManager | Path + artifact resolution for a model |
| ModelManager | Abstract training/evaluation/forecast flow control |
| ForecastingModelManager | Concrete forecasting implementation scaffold |
| EnsemblePathManager | Paths for multi-model ensemble |
| EnsembleManager | Aggregation + optional reconciliation |
| ExtractorPathManager | External raw data ingestion paths |
| ExtractorManager | Download → preprocess → save for external datasets |
| PostprocessorPathManager | Downstream transformation stage paths |
| PostprocessorManager | Read → transform → validate → save |
| PackageManager | Create/validate Poetry packages |
| ConfigurationManager | Merge + validate layered configuration |
Each manager has accompanying documentation in its module directory.
| Module | Role |
|---|---|
| dataloaders | Partition-aware data retrieval + drift detection + incremental update |
| transformations | Dataset transformation undo/management |
| reconciliation | Hierarchical grid ↔ country alignment |
| reports | Tailwind-styled HTML evaluation/forecast report generation |
| mapping | Static + interactive choropleth maps (matplotlib / Plotly) |
| logging | Central logging configuration injection |
| statistics | Forecast reconciliation math (proportional scaling) |
| wandb | Alerts, artifact logging, run lifecycle |
| model validation | Structural & logical integrity checks |
| ensemble validation | Structural & logical integrity checks |
| Module | Role |
|---|---|
| cli | CLI parsing and validation |
| dataset | Spatio-temporal dataset handler with country and priogrid level support |
- Querysets define feature/target extraction logic + transformation chains.
- Incremental updates replace raw slices (GED / ACLED) and replay transformations (UpdateViewser).
- MultiIndex structure:
(month_id, entity_id)for time-spatial operations. - Data types normalized (
float64for numeric integrity). - Partitions defined via month ranges (train/test or forecast horizon).
Evaluation produces:
- Step-wise metrics (per forecast horizon)
- Month-wise metrics (temporal slices)
- Time-series metrics (sequence performance trajectory)
Conflict type auto-inferred from target tokens (sb / ns / os). Files named per ADR conventions (artifact/output naming).
Ensures priogrid sums align with authoritative country totals while preserving relative spatial pattern and zero inflation. Parallelizable across countries × time × targets. Integrated into ensembles or model forecast postprocessing.
| Component | Feature |
|---|---|
| ReportModule | Headings, paragraphs, Markdown, tables, images, grids |
| MappingModule | Country & priogrid choropleths (static + interactive animation) |
| Templates | Forecast + evaluation report skeletons |
| CSS | Tailwind subset embedded for portability |
Reports embed:
- Metrics tables
- Key–value configuration summaries
- Spatial animations (Plotly)
- Artifact provenance (timestamps, versions)
Dataclass-driven (ForecastingModelArgs):
- Flags:
--train,--evaluate,--forecast,--report,--sweep,--prediction_store,--monthly - Validation prevents illegal combinations (e.g., evaluate with forecasting run type).
- Monthly shortcut auto-configures production cycle.
ConfigurationManager merges:
- Deployment
- Hyperparameters
- Meta
- Partition dictionary
- Runtime overrides (highest priority)
Forecast partitions dynamically adjusted by override_timestep. Validation enforces structural integrity and target specification.
PackageManager:
- Validates naming (
organization-prefix-*) - Creates Poetry skeleton (Python version constraint)
- Adds dependencies (including views-pipeline-core)
- Fetches latest release (tags or GitHub API)
- Runs
poetry check
- YAML-driven configuration (handlers, levels, formatters).
- Dedicated model/ensemble logging directories.
- Standard separation: main log, error log.
- WandB alerts for stage transitions, failures, reconciliation completeness.
| Task | Command |
|---|---|
| Run model | ./run.sh --run_type calibration --train --evaluate --report --saved |
| Run ensemble | ./run.sh --ensemble hybrid_lynx --forecast --report |
| Update raw data | Use --update_viewser |
| Generate report only | Use --evaluate --report or --forecast --report |
Refer to documentation/development_guidelines.md for coding standards and docstring_guidelines.md for formatting.
-
Run
build_model_scaffold.pyorbuild_ensemble_scaffold.pyfound in theviews-modelsrepository. -
Update
config_deployment.py,config_hyperparameters.py,config_queryset.py,config_meta.py. -
Run calibration:
python main.py --run_type calibration --train --evaluate --report
-
Run forecasting:
python main.py --run_type forecasting --train --forecast --report
-
View artifacts:
models/<name>/artifacts/
| Question | Answer |
|---|---|
| Do I need WandB? | Optional; disable notifications to run offline. |
| Can I reconcile single-model forecasts? | Yes—apply ReconciliationModule manually after forecast stage. |
| How do I add a new transformation? | Register callable in transformation mapping and ensure replay compatibility. |
| Are forecasts stored transformed or raw? | Temporarily reversed to raw scale before saving (pending ADR finalization). |
| Can I aggregate probabilistic outputs? | Current ensemble aggregation expects scalar or single-element lists. |


