Sanjay / train_models.py
TheDeepDas's picture
Docker
6c9c901
#!/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)