From e77314ff5474d03eda7e2a3e26c07dd0349c783c Mon Sep 17 00:00:00 2001 From: c72-taylor <Charlie3.Taylor@live.uwe.ac.uk> Date: Wed, 7 May 2025 20:00:28 +0100 Subject: [PATCH] model --- Working Models/Linear_training.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Working Models/Linear_training.py b/Working Models/Linear_training.py index 07a366d..f8e1b6d 100644 --- a/Working Models/Linear_training.py +++ b/Working Models/Linear_training.py @@ -269,19 +269,21 @@ def main(): with open(model_path, 'w') as f: json.dump(prediction_params, f, indent=2) - # Save human-readable results to the same directory - output_path = os.path.join(script_dir, "Training_Results.txt") + # Save human-readable metrics in the same folder as the input CSV + input_dir = os.path.dirname(file_path) if os.path.dirname(file_path) else "." + output_path = os.path.join(input_dir, "Model_Metrics.txt") with open(output_path, "w") as f: f.write(f"Train RMSE: {results['Train RMSE']}\n") f.write(f"Test RMSE: {results['Test RMSE']}\n") f.write(f"Train R² Score: {results['Train R² Score']}\n") f.write(f"Test R² Score: {results['Test R² Score']}\n") - f.write("\nBest piecewise linear model:") - f.write(str(results['Model'])) # Restore original stderr before printing sys.stderr = original_stderr + print(model_path) + print(output_path) + finally: # Restore original stderr and close the null file sys.stderr = original_stderr -- GitLab