File size: 1,233 Bytes
6c9c901
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/env python3
"""
Training script for the marine incident classification models
"""
import sys
import logging
from pathlib import Path

# Add the project root to the path
sys.path.append(str(Path(__file__).resolve().parent))

from app.services.ml_model import train_models

# Configure logging
logging.basicConfig(
    level=logging.INFO,
    format='%(asctime)s - %(name)s - %(levelname)s - %(message)s'
)

if __name__ == "__main__":
    print("Training Marine Incident Classification Models...")
    print("=" * 50)
    
    try:
        results = train_models()
        
        print("\nTraining completed successfully!")
        print(f"Threat Classification Accuracy: {results['threat_accuracy']:.3f}")
        print(f"Severity Assessment Accuracy: {results['severity_accuracy']:.3f}")
        
        print("\nThreat Distribution:")
        for threat, count in results['threat_distribution'].items():
            print(f"  {threat}: {count}")
        
        print("\nSeverity Distribution:")
        for severity, count in results['severity_distribution'].items():
            print(f"  {severity}: {count}")
            
    except Exception as e:
        print(f"Error during training: {e}")
        sys.exit(1)