Updated test.py and Jenkinsfile_4

This commit is contained in:
Jakub Henyk 2023-05-11 19:25:30 +02:00
parent a731bf8e26
commit da87b5f0c3
4 changed files with 28 additions and 13 deletions

View File

@ -23,21 +23,9 @@ pipeline {
}
}
}
//stage('Run Script') {
//steps {
//script {
//sh "chmod +x -R ${env.WORKSPACE}"
//sh './make_statistic.sh | tee output_statistic.txt'
// sh 'docker build . -t jhenyk/ium:latest'
// sh 'docker run jhenyk/ium:latest'
//sh 'node --version'
//}
//}
//}
stage('Archive Output') {
steps {
archiveArtifacts 'testresults.txt'
archiveArtifacts 'metrics.txt'
}
}
}

Binary file not shown.

4
metrics.txt Normal file
View File

@ -0,0 +1,4 @@
Accuracy: 0.5466666666666666
Precision: 0.5466666666666666
Recall: 1.0
F-score: 0.7068965517241379

23
test.py
View File

@ -81,4 +81,27 @@ if __name__ == '__main__':
the_file.write(f'data: {item[0][i]} \n true value: {item[1][i]} \n prediction: {item[2][i]}\n')
print(f'data: {item[0][i]} \n true value: {item[1][i]} \n prediction: {item[2][i]}\n')
tp = 0
tn = 0
fp = 0
fn = 0
for item in testdata:
for i in range(len(item)):
if int(item[1][i]) and int(item[2][i]):
tp += 1
elif not int(item[1][i]) and not int(item[2][i]):
tn += 1
elif not int(item[1][i]) and int(item[2][i]):
fp += 1
elif int(item[1][i]) and not int(item[2][i]):
fn += 1
accuracy = (tp + tn) / (tp + tn + fp + fn)
precision = tp / (tp + fp)
recall = tp / (tp + fn)
fscore = (2 * precision * recall) / (precision + recall)
with open('metrics.txt', 'w') as the_file:
the_file.write(f'Accuracy: {accuracy} \nPrecision: {precision} \nRecall: {recall} \nF-score: {fscore} \n')