plotting and eval metrics

This commit is contained in:
gedin 2023-05-24 16:45:29 +02:00
parent 41c655024d
commit 0d495bc36f
3 changed files with 40 additions and 1 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

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

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