Improve the frontend 2
This commit is contained in:
@@ -41,6 +41,7 @@ from app.services.training_events import (
|
||||
)
|
||||
from app.core.config import settings
|
||||
from app.core.database import get_db
|
||||
from app.models import AuditLog
|
||||
|
||||
logger = structlog.get_logger()
|
||||
route_builder = RouteBuilder('training')
|
||||
@@ -48,7 +49,7 @@ route_builder = RouteBuilder('training')
|
||||
router = APIRouter(tags=["training-operations"])
|
||||
|
||||
# Initialize audit logger
|
||||
audit_logger = create_audit_logger("training-service")
|
||||
audit_logger = create_audit_logger("training-service", AuditLog)
|
||||
|
||||
# Redis client for rate limiting
|
||||
_redis_client = None
|
||||
|
||||
@@ -263,10 +263,14 @@ class ModelRepository(TrainingBaseRepository):
|
||||
|
||||
average_mape = accuracy_row.average_mape if accuracy_row and accuracy_row.average_mape else 0
|
||||
total_models_with_metrics = accuracy_row.total_models_with_metrics if accuracy_row else 0
|
||||
|
||||
|
||||
# Convert MAPE to accuracy percentage (lower MAPE = higher accuracy)
|
||||
# Use 100 - MAPE as a simple conversion, but cap it at reasonable bounds
|
||||
average_accuracy = max(0, min(100, 100 - float(average_mape))) if average_mape > 0 else 0
|
||||
# Return None if no models have metrics (no data), rather than 0
|
||||
if total_models_with_metrics == 0:
|
||||
average_accuracy = None
|
||||
else:
|
||||
average_accuracy = max(0, min(100, 100 - float(average_mape))) if average_mape > 0 else 0
|
||||
|
||||
return {
|
||||
"total_models": total_models,
|
||||
|
||||
Reference in New Issue
Block a user