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)