Update for Zadanie 6.2 - evaluation

This commit is contained in:
Zofia Galla 2021-05-02 22:20:05 +02:00
parent 8410fda504
commit 6a4fba089e
3 changed files with 70 additions and 0 deletions

36
Jenkinsfile_evaluation Normal file
View File

@ -0,0 +1,36 @@
pipeline {
agent {dockerfile true}
parameters {
buildSelector(
defaultSelector: lastSuccessful(),
description: 'Which build to use for copying test data',
name: 'BUILD_SELECTOR_CREATE_DATASET')
buildSelector(
defaultSelector: upstream(),
description: 'Which build to use for copying trained model',
name: 'BUILD_SELECTOR_TRAINING')
gitParameter branchFilter: 'origin/(.*)', defaultValue: 'master', name: 'BRANCH', type: 'PT_BRANCH'
}
stages {
stage('copyArtifacts') {
steps {
copyArtifacts fingerprintArtifacts: true, projectName: 's434684-create-dataset', selector: buildParameter('BUILD_SELECTOR_CREATE_DATASET')
copyArtifacts fingerprintArtifacts: true, projectName: 's434684-training/${params.BRANCH}', selector: buildParameter('BUILD_SELECTOR_TRAINING')
copyArtifacts fingerprintArtifacts: true, projectName: 's434684-evaluation/${params.BRANCH}', selector: lastSuccessful(), optional: True
}
}
stage('Sh script') {
steps {
sh 'chmod +x run_evaluation.sh'
sh './run_evaluation.sh'
}
}
stage('Archive artifacts') {
steps{
archiveArtifacts artifacts: 'evaluation.txt', 'mean_square_error.png'
}
}
}
}

View File

@ -0,0 +1,32 @@
import tensorflow as tf
from tf.keras.models import Sequential
from tf.keras import layers
# from keras.layers import Flatten,Dense,Dropout, GlobalAveragePooling2D
from tf.keras.optimizers import Adam
import numpy as np
import pandas as pd
from sklearn.metrics import mean_squared_error
import matplotlib.pyplot as plt
movies_test = pd.read_csv('movies_test.csv')
x_test = movies_test.copy()
y_test = x_test.pop('rottentomatoes_audience_score')
x_test.pop('Unnamed: 0')
model = keras.models.load_model('model_movies')
y_predicted = model.predict(x_test, batch_size=64)
error = mean_squared_error(y_test, y_predicted)
with open('evaluation.txt', 'a+') as f:
f.write('%d\n' % error)
errors = np.genfromtxt('evaluation.txt')
fig = plt.figure()
plt.plot(errors)
plt.title('Evaluation of trained models')
plt.ylabel('Mean squared error')
fig.savefig('mean_squared_error.png')

2
run_evaluation.sh Normal file
View File

@ -0,0 +1,2 @@
#!/bin/bash
python3 ium_zadanie6_evaluation.py