Skip to content
Snippets Groups Projects
Commit e77314ff authored by c72-taylor's avatar c72-taylor
Browse files

model

parent 3904f846
No related branches found
No related tags found
No related merge requests found
...@@ -269,19 +269,21 @@ def main(): ...@@ -269,19 +269,21 @@ def main():
with open(model_path, 'w') as f: with open(model_path, 'w') as f:
json.dump(prediction_params, f, indent=2) json.dump(prediction_params, f, indent=2)
# Save human-readable results to the same directory # Save human-readable metrics in the same folder as the input CSV
output_path = os.path.join(script_dir, "Training_Results.txt") 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: with open(output_path, "w") as f:
f.write(f"Train RMSE: {results['Train RMSE']}\n") f.write(f"Train RMSE: {results['Train RMSE']}\n")
f.write(f"Test RMSE: {results['Test 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"Train R² Score: {results['Train R² Score']}\n")
f.write(f"Test R² Score: {results['Test 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 # Restore original stderr before printing
sys.stderr = original_stderr sys.stderr = original_stderr
print(model_path)
print(output_path)
finally: finally:
# Restore original stderr and close the null file # Restore original stderr and close the null file
sys.stderr = original_stderr sys.stderr = original_stderr
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment