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
This commit is contained in:
parent
2192607bf6
commit
f0d391b2a1
@ -323,7 +323,13 @@ async def detect_anomalies(request: DetectRequest):
|
|||||||
detections = ml_detector.detect(df, mode='confidence')
|
detections = ml_detector.detect(df, mode='confidence')
|
||||||
# Convert to legacy format for compatibility
|
# Convert to legacy format for compatibility
|
||||||
for det in detections:
|
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:
|
else:
|
||||||
print("[DETECT] Using Legacy ML Analyzer")
|
print("[DETECT] Using Legacy ML Analyzer")
|
||||||
detections = ml_analyzer.detect(df, risk_threshold=request.risk_threshold)
|
detections = ml_analyzer.detect(df, risk_threshold=request.risk_threshold)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user