From 574f34d3b16a40e42a00c884237a74f5929d51b7 Mon Sep 17 00:00:00 2001 From: Sheaza Date: Tue, 14 May 2024 22:41:29 +0200 Subject: [PATCH] add plot --- evaluate/Jenkinsfile | 4 ++-- predict.py | 15 ++++++++++++++- requirements.txt | 3 ++- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/evaluate/Jenkinsfile b/evaluate/Jenkinsfile index b93b927..623e4c0 100644 --- a/evaluate/Jenkinsfile +++ b/evaluate/Jenkinsfile @@ -17,7 +17,7 @@ pipeline { steps { copyArtifacts fingerprintArtifacts: true, projectName: 'z-s464980-create-dataset', selector: buildParameter('BUILD_SELECTOR') copyArtifacts fingerprintArtifacts: true, projectName: 's464980-training/master', selector: buildParameter('BUILD_SELECTOR') - copyArtifacts fingerprintArtifacts: true, projectName: 's464980-evaluation/master', selector: buildParameter('BUILD_SELECTOR'), optional: true + // copyArtifacts fingerprintArtifacts: true, projectName: 's464980-evaluation/master', selector: buildParameter('BUILD_SELECTOR'), optional: true } } stage("Prediction") { @@ -31,7 +31,7 @@ pipeline { steps { sh "chmod +x ./predict.py" sh "python ./predict.py" - archiveArtifacts artifacts: 'predictions.txt,accuracy.txt', onlyIfSuccessful: true + archiveArtifacts artifacts: 'predictions.txt,accuracy.txt,rmse.jpg', onlyIfSuccessful: true } } } diff --git a/predict.py b/predict.py index 3ac3c8c..c4c2444 100644 --- a/predict.py +++ b/predict.py @@ -2,6 +2,8 @@ import pandas as pd from tensorflow import keras import numpy as np from sklearn.metrics import root_mean_squared_error +import matplotlib.pyplot as plt + np.set_printoptions(threshold=np.inf) data = pd.read_csv("df_test.csv") @@ -17,4 +19,15 @@ with open("predictions.txt", "w") as f: accuracy = root_mean_squared_error(y_test, predictions) with open("rmse.txt", 'a') as file: - file.write(str(accuracy)) + file.write(str(accuracy)+"\n") + +with open("rmse.txt", 'r') as file: + lines = file.readlines() + num_lines = len(lines) + lines = [float(line.replace("\n", "")) for line in lines] + +plt.plot(range(1, num_lines+1), lines) +plt.xlabel("Build number") +plt.ylabel("RMSE value") +plt.title("RMSE") +plt.savefig("rmse.jpg") diff --git a/requirements.txt b/requirements.txt index 19b368d..466028b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,5 @@ pandas scikit-learn tensorflow -numpy \ No newline at end of file +numpy +matplotlib \ No newline at end of file