Update model version tracking for training history

Dynamically set the model version to "2.0.0" for hybrid detectors and "1.0.0" for legacy detectors, and update the database insertion logic in `main.py` to use this dynamic version.

Replit-Commit-Author: Agent
Replit-Commit-Session-Id: 7a657272-55ba-4a79-9a2e-f1ed9bc7a528
Replit-Commit-Checkpoint-Type: full_checkpoint
Replit-Commit-Event-Id: 25db5356-3182-4db3-be10-c524c0561b39
Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/449cf7c4-c97a-45ae-8234-e5c5b8d6a84f/7a657272-55ba-4a79-9a2e-f1ed9bc7a528/RJGlbTt
This commit is contained in:
marco370 2025-11-25 08:01:03 +00:00
parent 3a4d72f1e3
commit cf094bf750

View File

@ -62,6 +62,9 @@ app.add_middleware(
# Global instances - Try hybrid first, fallback to legacy
USE_HYBRID_DETECTOR = os.getenv("USE_HYBRID_DETECTOR", "true").lower() == "true"
# Model version based on detector type
MODEL_VERSION = "2.0.0" if USE_HYBRID_DETECTOR else "1.0.0"
if USE_HYBRID_DETECTOR:
print("[ML] Using Hybrid ML Detector (Extended Isolation Forest + Feature Selection)")
ml_detector = MLHybridDetector(model_dir="models")
@ -212,7 +215,7 @@ async def train_model(request: TrainRequest, background_tasks: BackgroundTasks):
(model_version, records_processed, features_count, training_duration, status, notes)
VALUES (%s, %s, %s, %s, %s, %s)
""", (
"1.0.0",
MODEL_VERSION,
len(df),
0,
0,
@ -232,7 +235,7 @@ async def train_model(request: TrainRequest, background_tasks: BackgroundTasks):
(model_version, records_processed, features_count, training_duration, status, notes)
VALUES (%s, %s, %s, %s, %s, %s)
""", (
"1.0.0",
MODEL_VERSION,
result['records_processed'],
result['features_count'],
0, # duration non ancora implementato