Skip to main content

No project description provided

Project description

GitHub License GitHub branch check runs GitHub Issues or Pull Requests GitHub Release

VIEWS Twitter Header

VIEWS Evaluation ๐Ÿ“Š

Part of the VIEWS Platform ecosystem for large-scale conflict forecasting.


โš ๏ธ ATTENTION: Migration Notice (v0.4.0+)

The evaluation ontology has been updated to be more explicit and task-specific. If your pipeline broke after updating, please update your configuration dictionary. The library now distinguishes between regression vs classification tasks, and point vs sample predictions.

Key Changes:

  • targets is now regression_targets or classification_targets.
  • metrics is now regression_point_metrics.
  • All uncertainty keys have been renamed to sample (reflecting that we evaluate draws/samples from a distribution).
Legacy Key New Canonical Key
targets regression_targets
metrics regression_point_metrics
regression_uncertainty_metrics regression_sample_metrics
classification_uncertainty_metrics classification_sample_metrics

Note: Legacy keys still work but will trigger a DeprecationWarning.


๐Ÿ“š Table of Contents

  1. Overview
  2. Quick Start
  3. Role in the VIEWS Pipeline
  4. Features
  5. Installation
  6. Architecture
  7. Project Structure
  8. Contributing
  9. License
  10. Acknowledgements

๐Ÿง  Overview

The VIEWS Evaluation repository provides a standardized framework for assessing time-series forecasting models used in the VIEWS conflict prediction pipeline. It ensures consistent, robust, and interpretable evaluations through metrics tailored to conflict-related data, which often exhibit right-skewness and zero-inflation.

The library is built on a three-layer architecture with a framework-agnostic NumPy core, ensuring that all mathematical evaluation logic is independent of Pandas or any other data-frame library.


๐Ÿš€ Quick Start

from views_evaluation import EvaluationFrame, NativeEvaluator
import numpy as np

# 1. Construct EvaluationFrame with NumPy arrays
ef = EvaluationFrame(
    y_true=y_true_array,
    y_pred=y_pred_array,  # shape (N, S) where S >= 1
    identifiers={'time': times, 'unit': units, 'origin': origins, 'step': steps},
    metadata={'target': 'ged_sb_best'},
)

# 2. Configure and evaluate
config = {
    "steps": [1, 2, 3, 4, 5, 6],
    "regression_targets": ["ged_sb_best"],
    "regression_point_metrics": ["MSE", "RMSLE", "Pearson"],
}
evaluator = NativeEvaluator(config)
report = evaluator.evaluate(ef)

# 3. Access results
report.to_dataframe("step")          # pd.DataFrame
report.to_dict()                     # nested dict
report.get_schema_results("month")   # typed metrics dataclass

For the full walkthrough including input formatting and sample evaluation, see documentation/integration_guide.md.


๐ŸŒ Role in the VIEWS Pipeline

VIEWS Evaluation ensures forecasting accuracy and model robustness as the official evaluation component of the VIEWS ecosystem.

Pipeline Integration:

  1. Model Predictions โ†’
  2. EvaluationFrame (validated NumPy container) โ†’
  3. NativeEvaluator (metrics computation) โ†’
  4. EvaluationReport (structured results)

Integration with Other Repositories:


โœจ Features

  • Comprehensive Evaluation Framework: The NativeEvaluator provides structured, stateless evaluation of time series predictions across a 2ร—2 matrix of regression/classification tasks and point/sample prediction types.
  • Multiple Evaluation Schemas:
    • Step-wise evaluation: groups and evaluates predictions by the respective steps from all models.
    • Time-series-wise evaluation: evaluates predictions for each time-series.
    • Month-wise evaluation: groups and evaluates predictions at a monthly level.
  • Support for Multiple Metrics (see table below for details)

Available Metrics

Metrics are organized by the 2ร—2 evaluation matrix: task (regression / classification) ร— prediction type (point / sample).

Regression Point Metrics

Metric Key Description Status
Mean Squared Error MSE Average of squared differences โœ…
Mean Squared Log Error MSLE MSE computed on log-transformed values โœ…
Root Mean Squared Log Error RMSLE Square root of MSLE โœ…
Earth Mover's Distance EMD Wasserstein distance between distributions โœ…
Pearson Correlation Pearson Linear correlation between predictions and actuals โœ…
Mean Tweedie Deviance MTD Tweedie deviance (configurable power), ideal for zero-inflated data โœ…
Mean Prediction y_hat_bar Average of all predicted values (diagnostic) โœ…
Magnitude Calibration Ratio MCR_point Ratio of predicted to actual magnitude โœ…
Sinkhorn Distance SD Regularized optimal transport distance โŒ
pseudo-Earth Mover Divergence pEMDiv Efficient EMD approximation โŒ
Variogram Variogram Spatial/temporal correlation structure score โŒ

Regression Sample Metrics

Metric Key Description Status
Continuous Ranked Probability Score CRPS Calibration and sharpness of probabilistic forecasts โœ…
Threshold-Weighted CRPS twCRPS CRPS emphasizing values above a threshold โœ…
Mean Interval Score MIS Prediction interval width and coverage โœ…
Quantile Interval Score QIS Interval score at specified quantiles โœ…
Coverage Coverage Proportion of actuals within prediction intervals โœ…
Ignorance Score Ignorance Logarithmic scoring rule for probabilistic predictions โœ…
Mean Prediction y_hat_bar Average of all predicted values (diagnostic) โœ…
Magnitude Calibration Ratio MCR_sample Ratio of predicted to actual magnitude โœ…

Classification Point Metrics

Metric Key Description Status
Average Precision AP Area under precision-recall curve โœ…

Classification Sample Metrics

Metric Key Description Status
Continuous Ranked Probability Score CRPS Calibration and sharpness โœ…
Threshold-Weighted CRPS twCRPS CRPS emphasizing values above a threshold โœ…
Brier Score Brier Accuracy of probabilistic binary predictions โŒ
Jeffreys Divergence Jeffreys Symmetric measure of distribution difference โŒ

Note: Metrics marked โŒ are defined in the catalog but not yet implemented โ€” requesting them raises a clear ValueError.


๐Ÿ“ Configuration Schema

The NativeEvaluator accepts a configuration dictionary (EvaluationConfig TypedDict) with the following keys:

Key Type Description
steps List[int] List of forecast steps to evaluate (e.g., [1, 3, 6, 12]).
regression_targets List[str] List of continuous targets (e.g., ['ged_sb_best']).
regression_point_metrics List[str] Metrics to compute for regression point predictions.
regression_sample_metrics List[str] Metrics to compute for regression sample predictions (e.g., ['CRPS']).
classification_targets List[str] List of binary targets (e.g., ['by_sb_best']).
classification_point_metrics List[str] Metrics to compute for classification probability scores.
classification_sample_metrics List[str] Metrics to compute for classification sample predictions.
evaluation_profile str Named hyperparameter profile (default: "base"). See views_evaluation/profiles/.
metric_hyperparameters Dict[str, Dict] Per-metric overrides that take precedence over the profile.

Example Configuration:

config = {
    "steps": [1, 3, 6, 12],
    "regression_targets": ["ged_sb_best"],
    "regression_point_metrics": ["MSE", "RMSLE", "Pearson"],
    "regression_sample_metrics": ["CRPS", "twCRPS", "MIS", "Coverage"],
    "evaluation_profile": "base",  # or "hydranet_ucdp"
    "metric_hyperparameters": {
        "twCRPS": {"threshold": 10.0},  # override profile default
    },
}

  • Data Integrity Checks: Validates input arrays for shape consistency, NaN/infinity, and required identifiers.
  • Framework-Agnostic Core: All evaluation operates on pure NumPy arrays via EvaluationFrame.
  • Metric Catalog & Profiles: Hyperparameters are managed through named evaluation profiles with a Chain of Responsibility resolver (model overrides โ†’ profile โ†’ fail loud).

โš™๏ธ Installation

Prerequisites

  • Python >= 3.11

From PyPI

pip install views_evaluation

๐Ÿ— Architecture

The library follows a strict three-layer architecture (ADR-011):

Level 0 โ€” Pure Core (NumPy + SciPy only, zero framework imports)
  EvaluationFrame       Canonical data container (y_true, y_pred, identifiers)
  NativeEvaluator       Stateless evaluation engine (month/sequence/step schemas)
  MetricCatalog         Genome registry mapping metrics โ†’ functions + required params
  Profiles              Named hyperparameter sets (base, hydranet_ucdp, ...)

Level 1 โ€” Bridge / Adapter
  EvaluationFrame       Validated NumPy data container
  EvaluationReport      Results container with DataFrame/dict export

Level 2 โ€” Legacy Orchestrator
  MetricCatalog         Genome registry and parameter resolver

Key design decisions:

  • ADR-011: No Pandas/Polars imports in Level 0 โ€” math is framework-agnostic.
  • ADR-013: Fail-loud โ€” all structural failures raise exceptions with actionable messages, never silently degrade.
  • ADR-042: Metric catalog โ€” each metric declares its required hyperparameters ("genome"); values are resolved via Chain of Responsibility.

๐Ÿ—‚ Project Structure

views-evaluation/
โ”œโ”€โ”€ views_evaluation/
โ”‚   โ”œโ”€โ”€ __init__.py                        # Public API exports
โ”‚   โ”œโ”€โ”€ adapters/
โ”‚   โ”‚   โ””โ”€โ”€ __init__.py                     # Reserved for future framework bridges
โ”‚   โ”œโ”€โ”€ evaluation/
โ”‚   โ”‚   โ”œโ”€โ”€ config_schema.py               # EvaluationConfig TypedDict
โ”‚   โ”‚   โ”œโ”€โ”€ evaluation_frame.py            # Core data container
โ”‚   โ”‚   โ”œโ”€โ”€ evaluation_manager.py          # Legacy orchestrator (deprecated)
โ”‚   โ”‚   โ”œโ”€โ”€ evaluation_report.py           # Results container
โ”‚   โ”‚   โ”œโ”€โ”€ metric_catalog.py              # ADR-042 registry + resolver
โ”‚   โ”‚   โ”œโ”€โ”€ metrics.py                     # Typed metric dataclasses
โ”‚   โ”‚   โ”œโ”€โ”€ native_evaluator.py            # Core evaluation engine
โ”‚   โ”‚   โ””โ”€โ”€ native_metric_calculators.py   # Metric implementations
โ”‚   โ””โ”€โ”€ profiles/
โ”‚       โ”œโ”€โ”€ base.py                        # Standard hyperparameter defaults
โ”‚       โ””โ”€โ”€ hydranet_ucdp.py               # Domain-specific profile
โ”œโ”€โ”€ tests/                                 # 242 tests (Green/Beige/Red)
โ”œโ”€โ”€ documentation/
โ”‚   โ”œโ”€โ”€ ADRs/                              # 17 Architecture Decision Records
โ”‚   โ”œโ”€โ”€ CICs/                              # Class Intent Contracts
โ”‚   โ”œโ”€โ”€ integration_guide.md               # Full API walkthrough
โ”‚   โ””โ”€โ”€ evaluation_concepts.md             # Domain concepts
โ”œโ”€โ”€ pyproject.toml
โ””โ”€โ”€ README.md

๐Ÿค Contributing

We welcome contributions! Please follow the VIEWS Contribution Guidelines.


๐Ÿ“œ License

This project is licensed under the LICENSE file.


๐Ÿ’ฌ Acknowledgements

Views Funders

Special thanks to the VIEWS MD&D Team for their collaboration and support.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

views_evaluation-0.4.0.tar.gz (23.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

views_evaluation-0.4.0-py3-none-any.whl (24.2 kB view details)

Uploaded Python 3

File details

Details for the file views_evaluation-0.4.0.tar.gz.

File metadata

  • Download URL: views_evaluation-0.4.0.tar.gz
  • Upload date:
  • Size: 23.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.4.1 CPython/3.11.15 Linux/6.17.0-1013-azure

File hashes

Hashes for views_evaluation-0.4.0.tar.gz
Algorithm Hash digest
SHA256 f658c3dd433cde25d2b9e09b713966b00b59f55e296949314d741b02d73de2dd
MD5 1eb5399c166e885a8b3b33c2f1fc2b61
BLAKE2b-256 8895fbf70113baeddea48d73179980895069c0fca1c958e0e028edd699c3e246

See more details on using hashes here.

File details

Details for the file views_evaluation-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: views_evaluation-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 24.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.4.1 CPython/3.11.15 Linux/6.17.0-1013-azure

File hashes

Hashes for views_evaluation-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3047d550855462233b1254207d22b2fc9311dbc8c43fbbe030e0e08a087027d4
MD5 a267bd89cec9f15af49ff2a29fbd29dd
BLAKE2b-256 df49d62bf56f4efa845d43407ca4314736c09d2e3a1b89c5dabd3aa6f052a877

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page