Compare commits

...

2 Commits

Author SHA1 Message Date
Alicja Szulecka
520206ef22 plot 2024-04-30 16:25:37 +02:00
Alicja Szulecka
65bf01c425 Update Jenkinsfile 2024-04-30 16:11:33 +02:00
3 changed files with 38 additions and 5 deletions

13
Jenkinsfile vendored
View File

@ -17,6 +17,7 @@ pipeline {
steps { steps {
copyArtifacts fingerprintArtifacts: true, projectName: 'z-s464914-create-dataset', selector: buildParameter('BUILD_SELECTOR') copyArtifacts fingerprintArtifacts: true, projectName: 'z-s464914-create-dataset', selector: buildParameter('BUILD_SELECTOR')
copyArtifacts filter: '*', projectName: 's464914-training/experiments/', selector: buildParameter('BUILD_SELECTOR') copyArtifacts filter: '*', projectName: 's464914-training/experiments/', selector: buildParameter('BUILD_SELECTOR')
copyArtifacts filter: '*', projectName: 's464914-evaluation/evaluation/', selector: buildParameter('BUILD_SELECTOR'), optional: true
} }
} }
stage('Prediction') { stage('Prediction') {
@ -41,5 +42,17 @@ pipeline {
} }
} }
} }
stage('Plot Accuracy') {
steps {
script {
def customImage = docker.build("custom-image")
customImage.inside {
sh 'python3 ./plot.py'
archiveArtifacts artifacts: 'accuracy.png', onlyIfSuccessful: true
}
}
}
}
} }
} }

View File

@ -18,8 +18,7 @@ rmse = np.sqrt(mean_squared_error(true_labels, predicted_labels))
with open(r'metrics.txt', 'a') as fp: with open(r'metrics.txt', 'a') as fp:
fp.write(f"Accuracy: {accuracy}\n") fp.write(f"Accuracy: {accuracy}\n")
fp.write(f"Micro-average Precision: {precision_micro}\n") fp.write(f"Precision: {precision_micro}\n")
fp.write(f"Micro-average Recall: {recall_micro}\n") fp.write(f"Recall: {recall_micro}\n")
fp.write(f"Micro-average F1-score: {f1_micro}\n") fp.write(f"F1-score: {f1_micro}\n")
fp.write(f"RMSE: {rmse}\n") fp.write(f"RMSE: {rmse}\n")
fp.write("--------------------\n")

21
plot.py Normal file
View File

@ -0,0 +1,21 @@
import matplotlib.pyplot as plt
import numpy as np
accuracy = []
f = open("metrics.txt", "r")
for line in f:
parts = line.strip().split(' ')
if(parts[0] == 'Accuracy:'):
accuracy.append(float(parts[1]))
y_values = np.arange(1, len(accuracy) + 1)
plt.plot(y_values, accuracy, marker='o', linestyle='-', color='b')
plt.xlabel('Build Number')
plt.ylabel('Accuracy')
plt.title('Accuracy Plot')
plt.grid(True)
plt.show()
plt.savefig('accuracy.png')