From 0920a59d1f3b8ed4671b41e9b0ba8f034cd475b0 Mon Sep 17 00:00:00 2001 From: Mateusz Date: Sat, 4 May 2024 16:19:51 +0200 Subject: [PATCH] IUM_06 --- Jenkinsfile | 11 +++++++++-- metrics.py | 5 +++-- plot.py | 16 ++++++++++++++++ 3 files changed, 28 insertions(+), 4 deletions(-) create mode 100644 plot.py diff --git a/Jenkinsfile b/Jenkinsfile index 37d6928..f5d1de8 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -35,7 +35,7 @@ pipeline { } } - stage('Copy Artifacts from training job') { + stage('Copy Artifacts from evaluation job') { steps { copyArtifacts filter: 'evaluation/*', projectName: 's464913-evaluation/evaluation', selector: buildParameter('BUILD_SELECTOR'), optional: true } @@ -51,7 +51,14 @@ pipeline { stage('Run metrics script') { steps { sh 'chmod +x metrics.py' - sh 'python3 ./metrics.py' + sh "python3 ./metrics.py ${currentBuild.number}" + } + } + + stage('Run plot script') { + steps { + sh 'chmod +x plot.py' + sh 'python3 ./plot.py' } } diff --git a/metrics.py b/metrics.py index 50149f5..2807dff 100644 --- a/metrics.py +++ b/metrics.py @@ -1,10 +1,12 @@ from sklearn.metrics import confusion_matrix import pandas as pd +import sys def main(): y_test = pd.read_csv("data/y_test.csv") y_pred = pd.read_csv("evaluation/y_pred.csv", header=None) + build_number = sys.argv[1] cm = confusion_matrix(y_test, y_pred) print( @@ -14,8 +16,7 @@ def main(): accuracy = cm[1, 1] / (cm[1, 0] + cm[1, 1]) with open(r"evaluation/metrics.txt", "a") as f: - f.write(f"Accuracy: {accuracy}\n") - f.write(f"\n") + f.write(f"{accuracy},{build_number}\n") if __name__ == "__main__": diff --git a/plot.py b/plot.py new file mode 100644 index 0000000..a03c018 --- /dev/null +++ b/plot.py @@ -0,0 +1,16 @@ +import numpy as np + + +def main(): + accuracy = [] + + with open("evaluation/metrics.txt") as f: + for line in f: + if "Accuracy" in line: + accuracy.append(float(line.split(":")[1].strip())) + + build_numbers = np.arange(1, len(accuracy) + 1) + + +if __name__ == "__main__": + main()