diff --git a/Jenkinsfile_evaluation b/Jenkinsfile_evaluation index 066c982..404a504 100644 --- a/Jenkinsfile_evaluation +++ b/Jenkinsfile_evaluation @@ -11,31 +11,46 @@ pipeline { description: 'Which build to use for copying artifacts', name: 'WHICH_BUILD_TRAIN' ) + buildSelector( + defaultSelector: lastSuccessful(), + description: 'Which build to use for copying artifacts', + name: 'WHICH_BUILD_EVAL' + ) + gitParameter branchFilter: 'origin/(.*)', defaultValue: 'master', name: 'BRANCH', type: 'PT_BRANCH' } stages { stage('copyArtifacts') { steps { copyArtifacts fingerprintArtifacts: true, projectName: 's434804-create-dataset', selector: buildParameter('BUILD_SELECTOR') copyArtifacts fingerprintArtifacts: true, projectName: 's434804-training/master', selector: buildParameter('WHICH_BUILD_TRAIN') + copyArtifacts optional: true, fingerprintArtifacts: true, projectName: 's434804-evaluation/master', selector: buildParameter('WHICH_BUILD_EVAL') } } stage('evaluation') { steps { + sh 'buildNumber=$(echo $BUILD_NUMBER)' + sh 'python3 ./lab06-eval.py $BUILD_NUMBER' sh 'chmod +x tensor-eval.py' sh 'python3 "tensor-eval.py" >> evaluation.txt' + sh 'python3 tensor-plot.py' } } stage('archiveArtifacts') { steps{ archiveArtifacts 'evaluation.txt' + archiveArtifacts 'evaluation_plot.png' } } - stage('sendMail') { - steps{ - emailext body: currentBuild.result ?: 'EVALUATION SUCCESS', - subject: 's434804', - to: '26ab8f35.uam.onmicrosoft.com@emea.teams.ms' - } - } } + post { + success { + mail body: 'SUCCESS', subject: 's434804', to: '26ab8f35.uam.onmicrosoft.com@emea.teams.ms' + } + failure { + mail body: 'FAILURE', subject: 's434804', to: '26ab8f35.uam.onmicrosoft.com@emea.teams.ms' + } + changed { + mail body: 'CHANGED', subject: 's434804', to: '26ab8f35.uam.onmicrosoft.com@emea.teams.ms' + } + } } \ No newline at end of file diff --git a/tensor-eval.py b/tensor-eval.py index 873f39d..43f978b 100644 --- a/tensor-eval.py +++ b/tensor-eval.py @@ -1,21 +1,28 @@ -import numpy as np import pandas as pd +import sys from sklearn.linear_model import LinearRegression from sklearn.model_selection import train_test_split from sklearn.metrics import mean_squared_error as rmse - reg = LinearRegression() alldata = pd.read_csv( - 'test.csv', header=0, skipinitialspace=True, - usecols=['total_vaccinations', 'people_vaccinated', 'daily_vaccinations' ,'daily_vaccinations_per_million']).dropna() + 'test.csv', header=0, + usecols=['total_vaccinations', 'daily_vaccinations', 'people_fully_vaccinated']).dropna() -X = alldata[[c for c in alldata.columns if c != 'daily_vaccinations']] -y = alldata['daily_vaccinations'] +X = alldata['total_vaccinations'].to_numpy().ravel().reshape(-1, 1) +y = alldata['daily_vaccinations'].to_numpy().ravel().reshape(-1, 1) X_train, X_test, y_train, y_test = train_test_split(X, y, test_size = 0.2, random_state = 6) lin_reg = reg.fit(X_train, y_train) score = lin_reg.score(X_test, y_test) prediction = lin_reg.predict(X_test) + +build_no = sys.argv[1] if len(sys.argv) > 1 else 0 +data = {"rmse": [rmse], "build": [build_no]} +df = pd.DataFrame(data=data) + +with open("evaluation.csv", "a") as f: + df.to_csv(f, header=f.tell() == 0, index=False) + print("RMSE:", rmse(y_test, prediction, squared=False)) print("Score:", score) \ No newline at end of file diff --git a/tensor-plot.py b/tensor-plot.py new file mode 100644 index 0000000..58fddf1 --- /dev/null +++ b/tensor-plot.py @@ -0,0 +1,6 @@ +import pandas as pd +from matplotlib import pyplot as plt + +df = pd.read_csv("evaluation.csv") +df.plot(x="build", y="rmse") +plt.savefig("evaluation_plot.png") \ No newline at end of file