evaluation added
Some checks failed
s434742-training/pipeline/head This commit looks good
s434742-evaluation/pipeline/head There was a failure building this commit

This commit is contained in:
patrycjalazna 2021-05-08 13:28:34 +02:00
parent 27c3bbff96
commit 194b850413
15 changed files with 10110 additions and 3 deletions

View File

@ -18,10 +18,12 @@ WORKDIR /app
COPY ./requirements.txt ./
COPY ./avocado-preprocessing.py ./
COPY ./avocado-training.py ./
COPY ./avocado-evaluation.py ./
RUN chmod +x ./requirements.txt
RUN chmod +x ./avocado-preprocessing.py
RUN chmod +x ./avocado-training.py
RUN chmod +x ./avocado-evaluation.py
RUN pip3 install -r ./requirements.txt
# CMD python3 avocado-preprocessing.py

56
Jenkinsfile-evaluation Normal file
View File

@ -0,0 +1,56 @@
pipeline {
agent any
parameters {
buildSelector(
defaultSelector: lastSuccessful(),
description: 'Which build to use for copying artifacts',
name: 'BUILD_SELECTOR'
)
buildSelector(
defaultSelector: lastSuccessful(),
description: 'Which build to use for copying artifacts',
name: 'BUILD_SELECTOR_DATASET'
)
buildSelector(
defaultSelector: lastSuccessful(),
description: 'Which build to use for copying artifacts',
name: 'BUILD_SELECTOR_TRAINING'
)
}
stage('copy artifacts')
{
steps
{
copyArtifacts(fingerprintArtifacts: true, projectName: 's434742-create-dataset', selector: buildParameter('WHICH_BUILD_DATASET'))
copyArtifacts(fingerprintArtifacts: true, projectName: 's434742-training', selector: buildParameter('WHICH_BUILD_TRAINING'))
}
}
stage('docker-training') {
steps {
script {
def img = docker.build('patlaz/ium:1.0')
img.inside {
sh 'chmod +x avocado-evaluation.py'
sh 'python3 avocado-evaluation.py'
}
}
}
}
stage('sendMail') {
steps{
emailext body: currentBuild.result ?: 'SUCCESS',
subject: 's434742 evaluation',
to: '26ab8f35.uam.onmicrosoft.com@emea.teams.ms'
}
}
}
}

View File

@ -42,14 +42,14 @@ pipeline {
stage('archiveArtifacts') {
steps{
archiveArtifacts 'avocado-model.h5'
archiveArtifacts 'avocado_model.h5'
}
}
stage('sendMail') {
steps{
emailext body: currentBuild.result ?: 'SUCCESS',
subject: 's434742',
subject: 's434742 training',
to: '26ab8f35.uam.onmicrosoft.com@emea.teams.ms'
}
}

42
avocado-evaluation.py Normal file
View File

@ -0,0 +1,42 @@
import pandas as pd
import numpy as np
from tensorflow import keras
import matplotlib.pyplot as plt
from keras import backend as K
def recall_m(y_true, y_pred):
true_positives = K.sum(K.round(K.clip(y_true * y_pred, 0, 1)))
possible_positives = K.sum(K.round(K.clip(y_true, 0, 1)))
recall = true_positives / (possible_positives + K.epsilon())
return recall
def precision_m(y_true, y_pred):
true_positives = K.sum(K.round(K.clip(y_true * y_pred, 0, 1)))
predicted_positives = K.sum(K.round(K.clip(y_pred, 0, 1)))
precision = true_positives / (predicted_positives + K.epsilon())
return precision
def f1_m(y_true, y_pred):
precision = precision_m(y_true, y_pred)
recall = recall_m(y_true, y_pred)
return 2*((precision*recall)/(precision+recall+K.epsilon()))
# zaladowanie modelu
avocado_model = 'avocado-model.h5'
model = keras.models.load_model(avocado_model)
# odczytanie danych z plikow
avocado_train = pd.read_csv('avocado_train.csv')
avocado_test = pd.read_csv('avocado_test.csv')
avocado_validate = pd.read_csv('avocado_validate.csv')
# podzial na X i y
X_train = avocado_train[['average_price', 'total_volume', '4046', '4225', '4770', 'total_bags', 'small_bags', 'large_bags', 'xlarge_bags']]
y_train = avocado_train[['type']]
X_test = avocado_test[['average_price', 'total_volume', '4046', '4225', '4770', 'total_bags', 'small_bags', 'large_bags', 'xlarge_bags']]
y_test = avocado_test[['type']]
# ewaluacja
loss, accuracy, f1_score, precision, recall = model.evaluate(X_test, y_test, verbose=0)
with open('')

View File

@ -11,6 +11,7 @@ from tensorflow.keras.models import Model
from tensorflow.keras.callbacks import EarlyStopping
from keras.models import Sequential
# odczytanie danych z plików
avocado_train = pd.read_csv('avocado_train.csv')
avocado_test = pd.read_csv('avocado_test.csv')
avocado_validate = pd.read_csv('avocado_validate.csv')
@ -37,8 +38,11 @@ model.compile(loss='binary_crossentropy', optimizer='adam', metrics=['accuracy']
epochs = int(sys.argv[1])
batch_size = int(sys.argv[2])
# trenowanie modelu
model.fit(X_train, y_train, epochs=epochs, batch_size=batch_size, validation_data=(X_test, y_test))
model.save('avocado-model.h5')
# zapisanie modelu
model.save('avocado_model.h5')
# predict
predictions = model.predict(X_test)

View File

Can't render this file because it is too large.

View File

Can't render this file because it is too large.

BIN
data/avocado_model.h5 Normal file

Binary file not shown.

2001
data/avocado_test.csv Normal file

File diff suppressed because it is too large Load Diff

6001
data/avocado_train.csv Normal file

File diff suppressed because it is too large Load Diff

2001
data/avocado_validate.csv Normal file

File diff suppressed because it is too large Load Diff

View File

Can't render this file because it is too large.

View File

Can't render this file because it is too large.

View File

Can't render this file because it is too large.