feat(iace): risk as confidence range + label in benchmark tab

Report the tool's risk number as a plausible range with a confidence
label instead of a false-precision point value (confidence-aware
tonality — the assessment is confirmed by the DSB / safety expert).

- risk_estimation.go: EstimateConfidence (hoch/mittel/niedrig from how the
  contact mode resolved), EstimateRiskRange (S±1 and aggregate L=F+W+P ±1,
  the empirically validated per-parameter accuracy), RiskLevelRange; share
  the riskBandLabel thresholds with EstimateRiskLevel.
- risk_benchmark.go: RiskComparisonPair gains eng_risk_point/low/high +
  level + level_range + confidence; RiskAgreement gains high_confidence_pct.
- RiskComparison.tsx: per-hazard range "low–high (level range)" + point,
  confidence chip, and an aggregate confidence line; types in useBenchmark.ts.
- Unit tests for the range/confidence helpers.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Benjamin Admin
2026-06-10 23:04:56 +02:00
parent 97575cc9c0
commit a7dc12f30f
5 changed files with 225 additions and 37 deletions
@@ -19,6 +19,15 @@ type RiskComparisonPair struct {
EngAvoidance int `json:"eng_avoidance"`
FKScore float64 `json:"fk_score"`
FKBand string `json:"fk_band"`
// Confidence-aware risk: a point estimate plus a plausible low/high band and
// a confidence label, so the tool reports a RANGE (not a false-precision
// point) — the assessment is confirmed by the DSB / safety expert.
EngRiskPoint int `json:"eng_risk_point"`
EngRiskLow int `json:"eng_risk_low"`
EngRiskHigh int `json:"eng_risk_high"`
EngRiskLevel string `json:"eng_risk_level"` // band of the point value
EngRiskLevelRange string `json:"eng_risk_level_range"` // e.g. "mittelhoch"
Confidence string `json:"confidence"` // hoch / mittel / niedrig
}
// RiskAgreement aggregates how close the tool's risk numbers are to the GT.
@@ -28,14 +37,15 @@ type RiskAgreement struct {
FrequencyWithin1 float64 `json:"frequency_within1"`
ProbabilityWithin1 float64 `json:"probability_within1"`
AvoidanceWithin1 float64 `json:"avoidance_within1"`
RankConcordance float64 `json:"rank_concordance"` // Fine-Kinney vs GT R
RankConcordance float64 `json:"rank_concordance"` // Fine-Kinney vs GT R
HighConfidencePct float64 `json:"high_confidence_pct"` // share of matched hazards with "hoch" confidence
}
// ComputeRiskComparison derives the tool's risk numbers for each matched hazard
// and compares them to the professional's GT values.
func ComputeRiskComparison(matched []HazardMatchPair) ([]RiskComparisonPair, RiskAgreement) {
pairs := make([]RiskComparisonPair, 0, len(matched))
var sevOK, freqOK, probOK, avoidOK, n int
var sevOK, freqOK, probOK, avoidOK, n, hiConf int
var engFK, gtR []float64
for _, m := range matched {
@@ -54,11 +64,20 @@ func ComputeRiskComparison(matched []HazardMatchPair) ([]RiskComparisonPair, Ris
fk := SuggestFineKinney(cats, scenario, lifecycle, 0)
gt := m.GTEntry.RiskIn
rLow, rPoint, rHigh := EstimateRiskRange(engS, engF, engW, engP)
rLevel, rLevelRange := RiskLevelRange(rLow, rPoint, rHigh)
conf := EstimateConfidence(cats, scenario)
if conf == "hoch" {
hiConf++
}
pairs = append(pairs, RiskComparisonPair{
HazardName: m.GTEntry.HazardType,
GTSeverity: gt.S, GTFrequency: gt.F, GTProbability: gt.W, GTAvoidance: gt.P, GTRisk: gt.R,
EngSeverity: engS, EngFrequency: engF, EngProbability: engW, EngAvoidance: engP,
FKScore: fk.Score, FKBand: fk.Band,
EngRiskPoint: rPoint, EngRiskLow: rLow, EngRiskHigh: rHigh,
EngRiskLevel: rLevel, EngRiskLevelRange: rLevelRange, Confidence: conf,
})
if gt.S > 0 {
@@ -88,6 +107,9 @@ func ComputeRiskComparison(matched []HazardMatchPair) ([]RiskComparisonPair, Ris
agg.AvoidanceWithin1 = pct(avoidOK, n)
agg.RankConcordance = rankConcordance(engFK, gtR)
}
if len(pairs) > 0 {
agg.HighConfidencePct = pct(hiConf, len(pairs))
}
return pairs, agg
}