ids.alfacom.it/deployment/install_ml_deps.sh
marco370 75d3bd56a1 Simplify ML dependency to use standard Isolation Forest
Remove problematic Extended Isolation Forest dependency and leverage existing scikit-learn fallback for Python 3.11 compatibility.

Replit-Commit-Author: Agent
Replit-Commit-Session-Id: 7a657272-55ba-4a79-9a2e-f1ed9bc7a528
Replit-Commit-Checkpoint-Type: intermediate_checkpoint
Replit-Commit-Event-Id: 89ea874d-b572-40ad-9ac7-0c77d2b7d08d
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 17:44:11 +00:00

82 lines
2.4 KiB
Bash
Executable File
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/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