ids.alfacom.it/attached_assets/Pasted--deployment-train-hybrid-production-sh--1764007807845_1764007807845.txt
marco370 b88377e2d5 Adapt ML model to new database schema and automate training
Adjusts SQL queries and feature extraction to accommodate changes in the network_logs database schema, enabling automatic weekly retraining of the ML hybrid detector.

Replit-Commit-Author: Agent
Replit-Commit-Session-Id: 7a657272-55ba-4a79-9a2e-f1ed9bc7a528
Replit-Commit-Checkpoint-Type: intermediate_checkpoint
Replit-Commit-Event-Id: f4fdd53b-f433-44d9-9f0f-63616a9eeec1
Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/449cf7c4-c97a-45ae-8234-e5c5b8d6a84f/7a657272-55ba-4a79-9a2e-f1ed9bc7a528/2lUhxO2
2025-11-24 18:14:43 +00:00

55 lines
2.0 KiB
Plaintext

./deployment/train_hybrid_production.sh
=======================================================================
TRAINING HYBRID ML DETECTOR - DATI REALI
=======================================================================
📂 Caricamento credenziali database da .env...
✅ Credenziali caricate:
Host: localhost
Port: 5432
Database: ids_database
User: ids_user
Password: ****** (nascosta)
🎯 Parametri training:
Periodo: ultimi 7 giorni
Max records: 1000000
🐍 Python: /opt/ids/python_ml/venv/bin/python
📊 Verifica dati disponibili nel database...
primo_log | ultimo_log | periodo_totale | totale_records
---------------------+---------------------+----------------+----------------
2025-11-22 10:03:21 | 2025-11-24 17:58:17 | 2 giorni | 234,316,667
(1 row)
🚀 Avvio training...
=======================================================================
[WARNING] Extended Isolation Forest not available, using standard IF
======================================================================
IDS HYBRID ML TRAINING - UNSUPERVISED MODE
======================================================================
[TRAIN] Loading last 7 days of real traffic from database...
❌ Error: column "dest_ip" does not exist
LINE 5: dest_ip,
^
Traceback (most recent call last):
File "/opt/ids/python_ml/train_hybrid.py", line 365, in main
train_unsupervised(args)
File "/opt/ids/python_ml/train_hybrid.py", line 91, in train_unsupervised
logs_df = train_on_real_traffic(db_config, days=args.days)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/ids/python_ml/train_hybrid.py", line 50, in train_on_real_traffic
cursor.execute(query, (days,))
File "/opt/ids/python_ml/venv/lib64/python3.11/site-packages/psycopg2/extras.py", line 236, in execute
return super().execute(query, vars)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
psycopg2.errors.UndefinedColumn: column "dest_ip" does not exist
LINE 5: dest_ip,
^