bluegreencity-ki

Plausibility Checks

Overview

The plausibility checks run automatically after the actual risk scoring. They are not intended to be a second modelling pass, but rather a technical and domain-level quality control layer.

In simple terms:

The implementation is located in bluegreencity_ki/plausibility/checker.py. Integration into the pipeline flow is done in bluegreencity_ki/pipelines/risk_scoring.py (repo-root paths — these links resolve in the repository, not on the docs site).

For operational use, plausibility artefacts are persisted both as files in the report directory and as PostGIS tables. This makes the diagnostic tables directly available to Apache Superset without parsing report files first.

Typical exported PostGIS table groups use the prefix plausibility_*, for example:

Why These Checks Were Introduced

The pipeline was already working correctly from a domain perspective, but with the new plausibility module it should become visible:

The plausibility module is therefore a combination of quality assurance, debugging support, and domain documentation.

Pipeline Flow

The order is now:

  1. Calculate criteria
  2. Aggregate total risk
  3. Optionally calculate ML risk
  4. Run plausibility checks
  5. Run validation against ground truth
  6. Write outputs and reports

Important:

Implemented Checks in the Static Branch

The static branch evaluates all activated criteria from config.yaml as well as the aggregated total risk.

1. Distribution Check

A simple statistical summary is calculated for each risk column:

Purpose:

2. Range Check

All risk values are checked for whether they fall within the expected range [0, 1].

Purpose in simple terms:

If values are outside the range, they are classified as critical.

3. Monotonicity Check

For selected criteria, it is verified whether the direction of risk development matches the domain expectation.

Examples:

Technically, the following happens:

Important:

Why this makes sense:

4. Spot Checks

A sample recompute is performed for a small allowlist of lightweight criteria.

The current default includes:

Procedure:

Why not for all criteria?

5. Spatial Check

It is checked how risks are distributed spatially across administrative units.

By default, grouping is done by stadtteil. If this column is not present, a spatial join can be performed using polygon layers.

Default layers used:

Calculated per area, among other things:

Why this is important:

6. Separate Full Matrix of Static Value Columns

In addition, there is now a dedicated complete matrix for the static numeric value columns only.

This is explicitly different from the check on risk scores.

The question asked here is:

Technically, the following happens:

Why this is important:

Implemented Checks in the ML Branch

The ML branch only runs when drought_risk_ml is present.

1. Correlation Analysis

A sample is drawn from the numeric ML features. Pearson and Spearman correlation matrices are calculated on this sample.

Important for the current implementation:

Goal:

In the report, mainly the strongly correlated pairs are highlighted.

2. Explainability / Feature Importance

SHAP is currently not the default path.

Instead, the built-in AutoGluon feature importance is used. This is more stable and directly accessible via the loaded model.

In simple terms:

3. PCA

PCA projects the numeric ML input features into new axes that explain as much shared structure as possible.

In simple terms:

Important:

When activated, the following are exported:

Domain benefit:

4. Species Clustering

The cluster analysis groups species by their position in the numeric feature space.

Important:

Current procedure:

Why risk scores are not directly included in cluster formation:

What this gives you:

5. Comparison with Ampelliste

This part is prepared but only active when an external “Ampelliste” list is configured later.

Then:

Currently, this part is intentionally optional.

Configuration

Control is via config/config.yaml (section plausibility).

Important blocks:

Current production defaults are deliberately conservative:

Report and Artefacts

The run reports now include a dedicated plausibility section.

The following are written:

Typical artefacts:

In addition, the report context contains two groups of images that are easy to confuse:

In simple terms:

Stability Decisions During Implementation

When introducing the plausibility module, several things had to be made deliberately more robust:

Spearman Removed from Critical Paths

The original pandas/scipy correlation paths caused native crashes on Windows. They were therefore replaced with explicit, controlled calculations.

Recompute Spot Checks Limited

Some expensive raster criteria would effectively run the entire pipeline twice in a spot check. An allowlist exists for this reason.

Plausibility is Non-Blocking

If a plausibility part fails, the main result should not be lost. Therefore, errors are logged and included in the report rather than hard-stopping the pipeline.

Diagnostic Scripts

The diagnostic scripts were moved to scripts/debug/ to keep the regular project scripts clean.

There are now targeted helpers for:

These scripts are explicitly debug tools and not part of the normal production run.

Domain Context of the ML Correlation Heatmap

The file report/plausibility/ml_correlation_heatmap.png shows the correlations between numeric ML input features, not between all criteria of the static model.

Important:

In simple terms:

Domain Context of the Static Value Full Matrix

The static value full matrix complements the ML heatmap with a second perspective.

It does not answer the question:

but rather:

This makes it particularly important for the domain evaluation of the criteria logic.

Examples for interpretation:

Particularly the negative correlations are of domain interest, as they can point to opposing site logics, for example more shading combined with lower heat load.

Are the Raw Criterion Values Also Analysed Against Each Other?

Yes. Since the current extension, there is a dedicated complete pairwise comparison of all available static numeric value columns.

The current state is:

In simple terms:

Notes for Domain Users

For domain interpretation, three levels are important:

  1. Static criterion: Checks whether an individual domain influence factor works sensibly on its own.

  2. Spatial plausibility: Checks whether high or low risks cluster in comprehensible sub-areas.

  3. ML plausibility: Checks whether the data-driven model operates with an internally comprehensible structure.

These levels answer different questions:

Particularly important for domain users:

Summary in Simple Terms

The plausibility module now answers four simple questions:

  1. Are the values technically valid?
  2. Do the criteria behave as one would expect from a domain perspective?
  3. Can results be cleanly reproduced on a sample basis?
  4. Does the ML model operate in an internally comprehensible and non-contradictory way?

That is exactly what this module was built for. It makes the pipeline more transparent, easier to debug, and more thoroughly verifiable from a domain perspective, without unnecessarily blocking the normal run.