feat(model_selection): add timing for model training and validation processes

This commit is contained in:
nuluh
2025-07-28 05:20:10 +07:00
parent 80d4a66925
commit 3cbef17b0c

View File

@@ -117,11 +117,20 @@ def train_and_evaluate_model(
result = {"model": model_name, "sensor": sensor_label, "success": False}
try:
import time
start_time = time.time()
# Train the model
model.fit(x_train, y_train)
result["elapsed_time_training"] = time.time() - start_time
try:
# Predict on the test set (validation)
start_time = time.time()
y_pred = model.predict(x_test)
result["elapsed_time_validation"] = time.time() - start_time
result["y_pred"] = y_pred # Convert to numpy array
except Exception as e:
result["error"] = f"Prediction error: {str(e)}"