From 5e28406d7cf8dd16208ff10201d16ca05d96071f Mon Sep 17 00:00:00 2001 From: Dominik Strzako Date: Sat, 15 May 2021 15:33:42 +0200 Subject: [PATCH] First evaluation test --- Jenkinsfile_create_dataset | 4 +--- Jenkinsfile_dataset_stats | 2 +- Jenkinsfile_evaluation | 32 +++++++++++++++++++++++++++++--- Zadanie_06_evaluate.py | 37 ++++++++++++++++++++++++++++++++++++- 4 files changed, 67 insertions(+), 8 deletions(-) diff --git a/Jenkinsfile_create_dataset b/Jenkinsfile_create_dataset index 9a33a49..f94910b 100644 --- a/Jenkinsfile_create_dataset +++ b/Jenkinsfile_create_dataset @@ -1,7 +1,5 @@ pipeline { - agent { - dockerfile true - } + agent {docker { image 'snowycocoon/ium_434788:3'}} //Definijuemy parametry, które będzie można podać podczas wywoływania zadania parameters { string ( diff --git a/Jenkinsfile_dataset_stats b/Jenkinsfile_dataset_stats index 9e8d2d3..23e7f24 100644 --- a/Jenkinsfile_dataset_stats +++ b/Jenkinsfile_dataset_stats @@ -1,6 +1,6 @@ pipeline { agent { - docker { image 'snowycocoon/ium_434788:2' } + docker { image 'snowycocoon/ium_434788:3' } } stages { stage('Test') { diff --git a/Jenkinsfile_evaluation b/Jenkinsfile_evaluation index 8415a63..14f325a 100644 --- a/Jenkinsfile_evaluation +++ b/Jenkinsfile_evaluation @@ -1,10 +1,20 @@ pipeline { - agent {docker { image 'adnovac/ium_s434760:1.0' }} + agent {docker { image 'snowycocoon/ium_434788:3'}} parameters{ + buildSelector( + defaultSelector: lastSuccessful(), + description: 'Which build to use for copying data artifacts', + name: 'WHICH_BUILD_DATA' + ) buildSelector( defaultSelector: lastSuccessful(), - description: 'Which build to use for copying artifacts', - name: 'WHICH_BUILD' + description: 'Which build to use for copying train artifacts', + name: 'WHICH_BUILD_TRAIN' + ) + buildSelector( + defaultSelector: lastSuccessful(), + description: 'Which build to use for copying current project artifacts', + name: 'WHICH_BUILD_THIS' ) } @@ -14,6 +24,22 @@ pipeline { steps { copyArtifacts(fingerprintArtifacts: true, projectName: 's434788-create-dataset', selector: buildParameter('WHICH_BUILD')) + copyArtifacts(fingerprintArtifacts: true, projectName: 's434788-training/master', selector: buildParameter('WHICH_BUILD_TRAIN')) + copyArtifacts(fingerprintArtifacts: true, optional: true, projectName: 's434788-evaluation/master', selector: buildParameter('WHICH_BUILD_THIS')) + } + } + stage('evaluate') + { + steps + { + catchError { + sh 'python3.8 Zadanie_06_evaluate.py' + } + } + } + stage('archive artifacts') { + steps { + archiveArtifacts 'results.txt,evaluation.png' } } } diff --git a/Zadanie_06_evaluate.py b/Zadanie_06_evaluate.py index 0f6c777..9d13e82 100644 --- a/Zadanie_06_evaluate.py +++ b/Zadanie_06_evaluate.py @@ -1 +1,36 @@ -print('evaluating') \ No newline at end of file +import pandas as pd +import numpy as np +from os import path +from tensorflow import keras +import sys +import matplotlib.pyplot as plt +from sklearn.metrics import accuracy_score, classification_report + +model = keras.models.load_model('saved_model.pb') +print('evaluating') + +test_df =pd.read_csv('test.csv') +y_test = test_df.quality +x_test = test_df.drop(['quality'], axis= 1) + +y_pred = model.predict(x_test) + +y_pred = np.around(y_pred, decimals=0) + +results = accuracy_score(y_test,y_pred) +with open('results.txt', 'a+', encoding="UTF-8") as f: + f.write(str(results) +"\n") + +with open('results.txt', 'r', encoding="UTF-8") as f: + lines = f.readlines() + +fig = plt.figure(figsize=(10,10)) + +chart = fig.add_subplot() +chart.set_ylabel("Accuracy") +chart.set_xlabel("Number of build") +x = np.arange(0, len(lines), 1) +y = [float(x) for x in lines] +print(y) +plt.plot(x,y,"ro") +plt.savefig("evaluation.png") \ No newline at end of file