evaluation

This commit is contained in:
Szymon Bartanowicz 2024-05-15 00:07:51 +02:00
parent f39bf64915
commit a6f8a4fe78
3 changed files with 97 additions and 26 deletions

77
Jenkinsfile vendored
View File

@ -1,37 +1,62 @@
pipeline { pipeline {
agent any agent {
dockerfile true
parameters {
string(name: 'CUTOFF', defaultValue: '100', description: 'Ilość wierszy do odcięcia')
string(name: 'KAGGLE_USERNAME', defaultValue: '', description: 'Kaggle username')
password(name: 'KAGGLE_KEY', defaultValue: '', description: 'Kaggle API key')
} }
triggers {
upstream(upstreamProjects: 's464937-training/training', threshold: hudson.model.Result.SUCCESS)
}
parameters {
buildSelector(defaultSelector: lastSuccessful(), description: 'Which build to use for copying artifacts', name: 'BUILD_SELECTOR')
gitParameter branchFilter: 'origin/(.*)', defaultValue: 'training', name: 'BRANCH', type: 'PT_BRANCH'
}
stages { stages {
stage('Clone repo') { stage('Clone Repository') {
steps { steps {
git branch: "main", url: "https://git.wmi.amu.edu.pl/s464937/ium_464937" git branch: 'evaluation', url: "https://git.wmi.amu.edu.pl/s464937/ium_464937"
} }
} }
stage('Copy Dataset Artifacts') {
steps {
copyArtifacts filter: 'data/dev.csv,data/test.csv,data/train.csv', projectName: 'z-s464937-create-dataset', selector: buildParameter('BUILD_SELECTOR')
}
}
stage('Copy Training Artifacts') {
steps {
copyArtifacts filter: 'powerlifting_model.h5', projectName: 's464937-training/' + params.BRANCH, selector: buildParameter('BUILD_SELECTOR')
}
}
stage('Copy Evaluation Artifacts') {
steps {
copyArtifacts filter: 'metrics.txt', projectName: '_s464937-evaluation/evaluation', selector: buildParameter('BUILD_SELECTOR'), optional: true
}
}
stage("Run predictions") {
steps {
sh "chmod +x ./predict.py"
sh "python3 ./predict.py"
archiveArtifacts artifacts: 'powerlifting_test_predictions.csv', onlyIfSuccessful: true
}
}
stage('Run metrics') {
steps {
sh 'chmod +x ./metrics.py'
sh "python3 ./metrics.py ${currentBuild.number}"
}
}
stage('Download and preprocess') { stage('Run plot') {
environment { steps {
KAGGLE_USERNAME = "szymonbartanowicz" sh 'chmod +x ./plot.py'
KAGGLE_KEY = "4692239eb65f20ec79f9a59ef30e67eb" sh 'python3 ./plot.py'
} }
steps {
withEnv([
"KAGGLE_USERNAME=${env.KAGGLE_USERNAME}",
"KAGGLE_KEY=${env.KAGGLE_KEY}"
]) {
sh "bash ./script1.sh ${params.CUTOFF}"
}
}
} }
stage('Archive') { stage('Archive Artifacts') {
steps { steps {
archiveArtifacts artifacts: 'data/*', onlyIfSuccessful: true archiveArtifacts artifacts: '*', onlyIfSuccessful: true
} }
} }
} }
} }

24
metrics.py Normal file
View File

@ -0,0 +1,24 @@
# import pandas as pd
# from sklearn.metrics import accuracy_score, precision_recall_fscore_support, mean_squared_error
# from math import sqrt
# import sys
#
# data = pd.read_csv('powerlifting_test_predictions.csv')
# y_pred = data['Predictions']
# y_test = data['Actual']
# y_test_binary = (y_test >= 3).astype(int)
#
# build_number = sys.argv[1]
#
# accuracy = accuracy_score(y_test_binary, y_pred.round())
# precision, recall, f1, _ = precision_recall_fscore_support(y_test_binary, y_pred.round(), average='micro')
# rmse = sqrt(mean_squared_error(y_test, y_pred))
#
# print(f'Accuracy: {accuracy}')
# print(f'Micro-avg Precision: {precision}')
# print(f'Micro-avg Recall: {recall}')
# print(f'F1 Score: {f1}')
# print(f'RMSE: {rmse}')
with open(r"metrics.txt", "a") as f:
f.write(f"{123},{1}\n")

22
plot.py Normal file
View File

@ -0,0 +1,22 @@
import matplotlib.pyplot as plt
def main():
accuracy = []
build_numbers = []
with open("maetrics.txt") as f:
for line in f:
accuracy.append(float(line.split(",")[0]))
build_numbers.append(int(line.split(",")[1]))
plt.plot(build_numbers, accuracy)
plt.xlabel("Build Number")
plt.ylabel("Accuracy")
plt.title("Accuracy of the model over time")
plt.xticks(range(min(build_numbers), max(build_numbers) + 1))
plt.show()
plt.savefig("plot.png")
if __name__ == "__main__":
main()