Compare commits

...

3 Commits

Author SHA1 Message Date
gedin cea42abe41 Merge branch 'tmp'
s470618-evaluation/pipeline/head There was a failure building this commit Details
2023-05-24 16:51:53 +02:00
gedin ac86a07ab8 files added 2023-05-24 16:48:12 +02:00
gedin 0d495bc36f plotting and eval metrics 2023-05-24 16:45:29 +02:00
5 changed files with 43 additions and 4 deletions

20
JenkinsfileEval Normal file
View File

@ -0,0 +1,20 @@
node {
stage('Preparation') {
checkout scm
copyArtifacts projectName: 's470618-metrics', filter: 'metrics.txt', fingerprintArtifacts: true, selector: lastSuccessful(), optional: true, target: './train-eval'
copyArtifacts projectName: 's470618-training', filter: '*.pt', fingerprintArtifacts: true, selector: lastSuccessful(), target: '.'
stage('Evaluate metrics') {
sh "pip install matplotlib"
sh "cd train-eval && ./eval.py"
sh "./plot_metrics.py"
}
}
stage('artifacts') {
echo 'saving artifacts'
archiveArtifacts 'metrics.txt', 'prediction.tsv', 'metrics.png'
}
}
}

View File

@ -1,6 +1,6 @@
node {
checkout scm
def dockerimage = docker.build("train-image", "./train-eval")
def dockerimage = docker.build("train-image", "dockerfile_train")
dockerimage.inside {
stage('Preparation') {
properties([

View File

@ -45,7 +45,7 @@ print ("The accuracy is", acc)
print ("The precission score is ", prec)
print ("The recall score is ", recall)
file = open('metrics.txt', 'w')
file = open('metrics.txt', 'a')
file.write(str(acc) + '\t' + str(prec) + '\t' + str(recall))
file.close()

View File

@ -3,7 +3,7 @@ import numpy as np
import torch
from torch import nn
import pandas as pd
import subprocess
# import subprocess
import sys
from sklearn.model_selection import train_test_split
@ -47,7 +47,7 @@ if __name__ == "__main__":
Y = df[['Survived']]
X.loc[:,('Sex')].replace(['female', 'male'], [0,1], inplace=True) #categorical data transformed to
X_train, X_test, Y_train, Y_test = train_test_split(X,Y, random_state=45, test_size=0.2, shuffle=True) #split the date into train and test sets
X_train, X_test, Y_train, Y_test = train_test_split(X,Y, test_size=0.2, shuffle=True) #split the date into train and test sets
testing_data = pd.concat([X_test, Y_test], axis=1)
testing_data.to_csv('testing_data.csv', sep=',')

19
train-eval/plot_metrics.py Executable file
View File

@ -0,0 +1,19 @@
#!/usr/bin/python3
import matplotlib
import matplotlib.pyplot as plt
data = []
with open('metrics.txt', 'r') as metrics:
for line in metrics:
data.append(line.strip().split('\t'))
# print(acc)
labels = ['accuracy','precision','recall']
builds = [x for x in range(len(data))]
fig = plt.figure()
ax = fig.add_subplot(1,1,1)
for i in range(3):
ax.plot(builds, [data[x][i] for x in range(len(data))], label=labels[i])
plt.legend()
plt.savefig('metrics.png')