From f0d391b2a17dbbead9cda9595533ee205919daee Mon Sep 17 00:00:00 2001 From: marco370 <48531002-marco370@users.noreply.replit.com> Date: Tue, 25 Nov 2025 09:34:44 +0000 Subject: [PATCH] Map confidence level strings to numeric values for detection results Converts 'high', 'medium', and 'low' confidence levels to their corresponding numeric values (95.0, 75.0, 50.0) before saving detection results to the database, resolving an invalid input syntax error for type numeric. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 7a657272-55ba-4a79-9a2e-f1ed9bc7a528 Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Event-Id: fd44e6f4-fc55-4636-aa7a-f4f462ac978a Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/449cf7c4-c97a-45ae-8234-e5c5b8d6a84f/7a657272-55ba-4a79-9a2e-f1ed9bc7a528/AXTUZmH --- python_ml/main.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/python_ml/main.py b/python_ml/main.py index eede93d..2115952 100644 --- a/python_ml/main.py +++ b/python_ml/main.py @@ -323,7 +323,13 @@ async def detect_anomalies(request: DetectRequest): detections = ml_detector.detect(df, mode='confidence') # Convert to legacy format for compatibility for det in detections: - det['confidence'] = det['confidence_level'] # Map confidence_level to confidence + # Map confidence_level string to numeric value for database + confidence_mapping = { + 'high': 95.0, + 'medium': 75.0, + 'low': 50.0 + } + det['confidence'] = confidence_mapping.get(det['confidence_level'], 50.0) else: print("[DETECT] Using Legacy ML Analyzer") detections = ml_analyzer.detect(df, risk_threshold=request.risk_threshold)