added plot and new parameters;change mail handling
Some checks failed
s434804-evaluation/pipeline/head There was a failure building this commit

This commit is contained in:
Dawid 2021-05-13 22:27:41 +02:00
parent af149190ea
commit f1af6da7f1
3 changed files with 41 additions and 13 deletions

View File

@ -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'
}
}
}

View File

@ -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)

6
tensor-plot.py Normal file
View File

@ -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")