#!/bin/bash # Script per installare dipendenze ML Hybrid Detector # SEMPLIFICATO: usa sklearn.IsolationForest (nessuna compilazione richiesta!) set -e echo "╔═══════════════════════════════════════════════╗" echo "║ INSTALLAZIONE DIPENDENZE ML HYBRID ║" echo "╚═══════════════════════════════════════════════╝" echo "" # Vai alla directory python_ml cd "$(dirname "$0")/../python_ml" || exit 1 echo "📍 Directory corrente: $(pwd)" echo "" # Verifica venv if [ ! -d "venv" ]; then echo "❌ ERRORE: Virtual environment non trovato in $(pwd)/venv" echo " Esegui prima: python3 -m venv venv" exit 1 fi # Attiva venv echo "🔧 Attivazione virtual environment..." source venv/bin/activate # Verifica che stiamo usando il venv PYTHON_PATH=$(which python) echo "📍 Python in uso: $PYTHON_PATH" if [[ ! "$PYTHON_PATH" =~ "venv" ]]; then echo "⚠️ WARNING: Non stiamo usando il venv correttamente!" fi echo "" # STEP 1: Aggiorna pip/setuptools/wheel echo "📦 Step 1/2: Aggiornamento pip/setuptools/wheel..." python -m pip install --upgrade pip setuptools wheel if [ $? -eq 0 ]; then echo "✅ pip/setuptools/wheel aggiornati" else echo "❌ Errore durante aggiornamento pip" exit 1 fi echo "" # STEP 2: Installa dipendenze ML da requirements.txt echo "📦 Step 2/2: Installazione dipendenze ML..." python -m pip install xgboost==2.0.3 joblib==1.3.2 if [ $? -eq 0 ]; then echo "✅ Dipendenze ML installate con successo" else echo "❌ Errore durante installazione dipendenze ML" exit 1 fi echo "" echo "✅ INSTALLAZIONE COMPLETATA!" echo "" echo "🧪 Test import componenti ML..." python -c "from sklearn.ensemble import IsolationForest; from xgboost import XGBClassifier; print('✅ sklearn IsolationForest OK'); print('✅ XGBoost OK')" if [ $? -eq 0 ]; then echo "" echo "✅ TUTTO OK! Hybrid ML Detector pronto per l'uso" echo "" echo "ℹ️ INFO: Sistema usa sklearn.IsolationForest (compatibile Python 3.11+)" echo "" echo "📋 Prossimi step:" echo " 1. Test rapido: python train_hybrid.py --mode test" echo " 2. Training completo: python train_hybrid.py --mode train" else echo "❌ Errore durante test import componenti ML" exit 1 fi