evaluation (first attempt)

This commit is contained in:
Anna Nowak 2021-04-29 23:45:22 +02:00
parent 522f357fd4
commit 4713bdefea
7 changed files with 1892 additions and 1800 deletions

1
.gitignore vendored
View File

@ -64,3 +64,4 @@ dev.csv
*.txt *.txt
.venv/ .venv/
model.h5 model.h5
evaluation.png

View File

@ -9,3 +9,4 @@ RUN pip3 install -r requirements.txt
COPY ["Zadanie 1.py", "."] COPY ["Zadanie 1.py", "."]
COPY ["stats.py", "."] COPY ["stats.py", "."]
COPY ["train.py", "."] COPY ["train.py", "."]
COPY ["evaluate.py", "."]

54
Jenkinsfile-evaluation Normal file
View File

@ -0,0 +1,54 @@
pipeline {
agent {
docker { image 'adnovac/ium_s434760:1.1' }
}
parameters{
buildSelector(
defaultSelector: lastSuccessful(),
description: 'Which build to use for copying data artifacts',
name: 'WHICH_BUILD_DATA'
)
buildSelector(
defaultSelector: lastSuccessful(),
description: 'Which build to use for copying train artifacts',
name: 'WHICH_BUILD_TRAIN'
)
buildSelector(
defaultSelector: lastSuccessful(),
description: 'Which build to use for copying current project artifacts',
name: 'WHICH_BUILD_THIS'
)
}
stages {
stage('copy artifacts')
{
steps
{
copyArtifacts(fingerprintArtifacts: true, projectName: 's434760-create-dataset', selector: buildParameter('WHICH_BUILD_DATA'))
copyArtifacts(fingerprintArtifacts: true, projectName: 's434760-training', selector: buildParameter('WHICH_BUILD_TRAIN'))
copyArtifacts(fingerprintArtifacts: true, projectName: 's434760-evaluation', selector: buildParameter('WHICH_BUILD_THIS'))
}
}
stage('train')
{
steps
{
catchError {
sh 'python3.8 evaluate.py ${BATCH_SIZE} ${EPOCHS}'
}
}
}
stage('archive artifacts') {
steps {
archiveArtifacts 'results.txt,evaluation.png'
}
}
stage('send email') {
steps {
emailext body: currentBuild.result ?: 'SUCCESS',
subject: 's434760 - validation',
to: 'annnow19@st.amu.edu.pl'
}
}
}
}

View File

@ -45,7 +45,7 @@ pipeline {
steps { steps {
emailext body: currentBuild.result ?: 'SUCCESS', emailext body: currentBuild.result ?: 'SUCCESS',
subject: 's434760 - train', subject: 's434760 - train',
to: '26ab8f35.uam.onmicrosoft.com@emea.teams.ms' to: 'annnow19@st.amu.edu.pl'
} }
} }
} }

35
evaluate.py Normal file
View File

@ -0,0 +1,35 @@
import pandas as pd
import numpy as np
from os import path
from tensorflow import keras
import sys
import matplotlib.pyplot as plt
model_name = "model.h5"
input_columns=["Age","Nationality","Position","Club"]
model = keras.models.load_model(model_name)
test_data=pd.read_csv('test.csv')
X_test=test_data[input_columns].to_numpy()
Y_test=test_data[["Overall"]].to_numpy()
#MeanSquaredError
results_test = model.evaluate(X_test, Y_test, batch_size=128)
with open('results.txt', 'a+', encoding="UTF-8") as f:
f.write(str(results_test) +"\n")
with open('results.txt', 'r', encoding="UTF-8") as f:
lines = f.readlines()
fig = plt.figure(figsize=(5,5))
chart = fig.add_subplot()
chart.set_ylabel("Mean squared error")
chart.set_xlabel("Number of build")
x = np.arange(0, len(lines), 1)
y = [float(x) for x in lines]
print(y)
plt.plot(x,y,"ro")
plt.savefig("evaluation.png")

View File

@ -4,3 +4,4 @@ numpy==1.19.2
sklearn sklearn
tensorflow==2.4.1 tensorflow==2.4.1
jinja2==2.11.3 jinja2==2.11.3
matplotlib

File diff suppressed because it is too large Load Diff