diff --git a/Working Models/Linear_training.py b/Working Models/Linear_training.py index 07a366d13f3bd2f48fee2ece11aac57bcd9bc6fb..f8e1b6d2e2435821f7150bb04a3c3ee65446fd98 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