add improvment on basle line finding

This commit is contained in:
larssand
2026-06-23 08:35:07 +02:00
parent 5bd5710ea0
commit 59c8758ec8
2 changed files with 8 additions and 4 deletions

View File

@@ -156,7 +156,8 @@ class BaselineStore:
reason = f"{field} value deviates from its stream baseline"
deviation = abs(current_value - mean(history))
if deviation > (pstdev(history) or 1.0) * 3:
output[entity].append({"field": field, "stream_id": stream, "score": 15, "reason": reason})
samples = sorted({event.fields.get(field, "") for event in events if event.fields.get("fgai_stream_id") == stream and event.fields.get(str(getattr(profiles.get(stream), "entity_field", "")).lower()) == entity and event.fields.get(field)})[:5]
output[entity].append({"field": field, "stream_id": stream, "score": 15, "reason": reason, "current": round(current_value, 2), "baseline": round(mean(history), 2), "sample_values": samples})
# Detect selected categorical values that have not appeared for this entity in prior data.
for event in events:
profile = profiles.get(event.fields.get("fgai_stream_id", ""))