IUM_06
This commit is contained in:
parent
59f3e55786
commit
8b9327c864
19
IUM_06-metrics.py
Normal file
19
IUM_06-metrics.py
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
from sklearn.metrics import confusion_matrix
|
||||||
|
import pandas as pd
|
||||||
|
import sys
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
y_test = pd.read_csv("beer_reviews_test.csv")
|
||||||
|
y_pred = pd.read_csv("beer_review_sentiment_predictions.csv", header=None)
|
||||||
|
build_number = sys.argv[1]
|
||||||
|
|
||||||
|
cm = confusion_matrix(y_test, y_pred)
|
||||||
|
accuracy = cm[1, 1] / (cm[1, 0] + cm[1, 1])
|
||||||
|
|
||||||
|
with open(r"beer_metrics.txt", "a") as f:
|
||||||
|
f.write(f"{accuracy},{build_number}\n")
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
24
IUM_06-plot.py
Normal file
24
IUM_06-plot.py
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
import matplotlib.pyplot as plt
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
accuracy = []
|
||||||
|
build_numbers = []
|
||||||
|
|
||||||
|
with open("beer_metrics.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("acc.png")
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
76
Jenkinsfile
vendored
76
Jenkinsfile
vendored
@ -1,52 +1,62 @@
|
|||||||
pipeline {
|
pipeline {
|
||||||
agent any
|
agent {
|
||||||
|
dockerfile true
|
||||||
parameters {
|
|
||||||
string(name: 'CUTOFF', defaultValue: '10000', description: 'Liczba wierszy do obcięcia ze zbioru danych')
|
|
||||||
string(name: 'KAGGLE_USERNAME', defaultValue: '', description: 'Kaggle username')
|
|
||||||
password(name: 'KAGGLE_KEY', defaultValue: '', description: 'Kaggle API key')
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
triggers {
|
||||||
|
upstream(upstreamProjects: 's464979-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 Repository') {
|
stage('Clone Repository') {
|
||||||
steps {
|
steps {
|
||||||
git url: "https://git.wmi.amu.edu.pl/s464979/ium_464979"
|
git branch: 'evaluation', url: "https://git.wmi.amu.edu.pl/s464979/ium_464979"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
stage('Download dataset') {
|
stage('Copy Dataset Artifacts') {
|
||||||
steps {
|
steps {
|
||||||
withEnv(["KAGGLE_USERNAME=${env.KAGGLE_USERNAME}", "KAGGLE_KEY=${env.KAGGLE_KEY}"]) {
|
copyArtifacts filter: 'beer_reviews.csv,beer_reviews_train.csv,beer_reviews_test.csv', projectName: 'z-s464979-create-dataset', selector: buildParameter('BUILD_SELECTOR')
|
||||||
sh "kaggle datasets download -d thedevastator/1-5-million-beer-reviews-from-beer-advocate --unzip"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
stage('Process and Split Dataset') {
|
stage('Copy Training Artifacts') {
|
||||||
agent {
|
steps {
|
||||||
dockerfile {
|
copyArtifacts filter: 'beer_review_sentiment_model.h5', projectName: 's464979-training/' + params.BRANCH, selector: buildParameter('BUILD_SELECTOR')
|
||||||
filename 'Dockerfile'
|
}
|
||||||
reuseNode true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
steps {
|
|
||||||
sh "chmod +x ./IUM_05-split.py"
|
|
||||||
sh "python3 ./IUM_05-split.py"
|
|
||||||
archiveArtifacts artifacts: 'beer_reviews.csv,beer_reviews_train.csv,beer_reviews_test.csv', onlyIfSuccessful: true
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
stage("Run") {
|
stage('Copy Evaluation Artifacts') {
|
||||||
agent {
|
steps {
|
||||||
dockerfile {
|
copyArtifacts filter: 'evaluation/*', projectName: 's464979-evaluation/evaluation', selector: buildParameter('BUILD_SELECTOR'), optional: true
|
||||||
filename 'Dockerfile'
|
}
|
||||||
reuseNode true
|
}
|
||||||
}
|
stage("Run predictions") {
|
||||||
}
|
|
||||||
steps {
|
steps {
|
||||||
sh "chmod +x ./IUM_05-model.py"
|
|
||||||
sh "chmod +x ./IUM_05-predict.py"
|
sh "chmod +x ./IUM_05-predict.py"
|
||||||
sh "python3 ./IUM_05-model.py"
|
|
||||||
sh "python3 ./IUM_05-predict.py"
|
sh "python3 ./IUM_05-predict.py"
|
||||||
archiveArtifacts artifacts: 'beer_review_sentiment_model.h5,beer_review_sentiment_predictions.csv', onlyIfSuccessful: true
|
archiveArtifacts artifacts: 'beer_review_sentiment_predictions.csv', onlyIfSuccessful: true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
stage('Run metrics') {
|
||||||
|
steps {
|
||||||
|
sh 'chmod +x ./IUM_06-metrics.py'
|
||||||
|
sh "python3 ./IUM_06-metrics.py ${currentBuild.number}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stage('Run plot') {
|
||||||
|
steps {
|
||||||
|
sh 'chmod +x ./IUM_06-plot.py'
|
||||||
|
sh 'python3 ./IUM_06-plot.py'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stage('Archive Artifacts') {
|
||||||
|
steps {
|
||||||
|
archiveArtifacts artifacts: '*', onlyIfSuccessful: true
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user