 ./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,
                    ^
