work on lab6
Some checks failed
s449288-training/pipeline/head There was a failure building this commit
Some checks failed
s449288-training/pipeline/head There was a failure building this commit
This commit is contained in:
parent
76657a9957
commit
8b663f423d
36
evaluate.py
Normal file
36
evaluate.py
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
import tensorflow as tf
|
||||||
|
from keras.models import load_model
|
||||||
|
from matplotlib import pyplot as plt
|
||||||
|
from matplotlib.ticker import MaxNLocator
|
||||||
|
|
||||||
|
# Załadowanie modelu z pliku
|
||||||
|
model = keras.models.load_model('lego_reg_model')
|
||||||
|
|
||||||
|
# Załadowanie zbioru testowego
|
||||||
|
test_piece_counts = np.array(data_test['piece_count'])
|
||||||
|
test_prices = np.array(data_test['list_price'])
|
||||||
|
|
||||||
|
# Prosta ewaluacja (mean absolute error)
|
||||||
|
test_results = model.evaluate(
|
||||||
|
test_piece_counts,
|
||||||
|
test_prices, verbose=0)
|
||||||
|
|
||||||
|
# Zapis wartości liczbowej metryki do pliku
|
||||||
|
with open('eval_results.txt', 'a+') as f:
|
||||||
|
f.write(test_results)
|
||||||
|
|
||||||
|
# Wygenerowanie i zapisanie do pliku wykresu
|
||||||
|
with open('eval_results.txt') as f:
|
||||||
|
scores = []
|
||||||
|
for line in f:
|
||||||
|
scores.append(float(line))
|
||||||
|
builds = list(range(1, len(scores) + 1))
|
||||||
|
|
||||||
|
plot = plt.plot(builds, scores)
|
||||||
|
plt.xlabel('Build number')
|
||||||
|
plt.xticks(range(1, len(scores) + 1))
|
||||||
|
plt.ylabel('Mean absolute error')
|
||||||
|
plt.title('Model error by build')
|
||||||
|
plt.savefig('error_plot.jpg')
|
||||||
|
plt.show()
|
||||||
|
|
@ -2,44 +2,43 @@ pipeline {
|
|||||||
agent {
|
agent {
|
||||||
dockerfile true
|
dockerfile true
|
||||||
}
|
}
|
||||||
parameters {
|
|
||||||
string(
|
|
||||||
defaultValue: '100',
|
|
||||||
description: 'Example training parameter',
|
|
||||||
name: 'EPOCHS_NUM'
|
|
||||||
)
|
|
||||||
}
|
|
||||||
stages {
|
stages {
|
||||||
stage('Stage 1') {
|
stage('Stage 1') {
|
||||||
steps {
|
steps {
|
||||||
sh 'chmod u+x ./simple_regression.py'
|
sh 'chmod u+x ./evaluate.py'
|
||||||
echo 'Copying datasets from create-dataset...'
|
echo 'Copying datasets from the create-dataset job...'
|
||||||
copyArtifacts filter: '*', projectName: 's449288-create-dataset'
|
copyArtifacts filter: 'lego_sets_clean_test.csv', projectName: 's449288-create-dataset'
|
||||||
echo 'Datasets copied'
|
echo 'Datasets copied'
|
||||||
echo 'Conducting simple regression model test'
|
echo 'Copying model from the training job...'
|
||||||
sh 'python3 simple_regression.py $EPOCHS_NUM'
|
copyArtifacts filter: 'lego_reg_model.tar.gz', projectName: 's449288-training'
|
||||||
echo 'Model and predictions saved'
|
echo 'Model copied'
|
||||||
sh 'head lego_reg_results.csv'
|
sh 'tar xvzf lego_reg_model.tar.gz'
|
||||||
sh 'ls -lh lego_reg_model'
|
echo 'Optional copying of the metrics file from previous build...'
|
||||||
echo 'Archiving model...'
|
copyArtifacts filter: 'eval_results.txt', projectName: 's449288-evaluation', optional: 'True'
|
||||||
sh 'tar -czf lego_reg_model.tar.gz lego_reg_model/'
|
echo 'Metrics file copied if it didn't exist'
|
||||||
archiveArtifacts 'lego_reg_model.tar.gz'
|
echo 'Evaluating model...'
|
||||||
echo 'Model archived'
|
sh 'python3 evaluate.py'
|
||||||
|
echo 'Model evaluated. Metrics saved. Plot saved.'
|
||||||
|
sh 'head eval_results.txt'
|
||||||
|
sh 'file error_plot.jpg'
|
||||||
|
echo 'Archiving metrics file...'
|
||||||
|
archiveArtifacts 'eval_results.txt'
|
||||||
|
echo 'File archived'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
post {
|
post {
|
||||||
success {
|
success {
|
||||||
emailext body: 'SUCCESS', subject: 's449288-training build status', to: 'e19191c5.uam.onmicrosoft.com@emea.teams.ms'
|
emailext body: 'SUCCESS', subject: 's449288-evaluation build status', to: 'e19191c5.uam.onmicrosoft.com@emea.teams.ms'
|
||||||
}
|
}
|
||||||
failure {
|
failure {
|
||||||
emailext body: 'FAILURE', subject: 's449288-training build status', to: 'e19191c5.uam.onmicrosoft.com@emea.teams.ms'
|
emailext body: 'FAILURE', subject: 's449288-evaluation build status', to: 'e19191c5.uam.onmicrosoft.com@emea.teams.ms'
|
||||||
}
|
}
|
||||||
unstable {
|
unstable {
|
||||||
emailext body: 'UNSTABLE', subject: 's449288-training build status', to: 'e19191c5.uam.onmicrosoft.com@emea.teams.ms'
|
emailext body: 'UNSTABLE', subject: 's449288-evaluation build status', to: 'e19191c5.uam.onmicrosoft.com@emea.teams.ms'
|
||||||
}
|
}
|
||||||
changed {
|
changed {
|
||||||
emailext body: 'CHANGED', subject: 's449288-training build status', to: 'e19191c5.uam.onmicrosoft.com@emea.teams.ms'
|
emailext body: 'CHANGED', subject: 's449288-evaluation build status', to: 'e19191c5.uam.onmicrosoft.com@emea.teams.ms'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -25,6 +25,8 @@ pipeline {
|
|||||||
sh 'tar -czf lego_reg_model.tar.gz lego_reg_model/'
|
sh 'tar -czf lego_reg_model.tar.gz lego_reg_model/'
|
||||||
archiveArtifacts 'lego_reg_model.tar.gz'
|
archiveArtifacts 'lego_reg_model.tar.gz'
|
||||||
echo 'Model archived'
|
echo 'Model archived'
|
||||||
|
echo 'Launching the s449288-evaluation job...'
|
||||||
|
build job: 's449288-evaluation/master/'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user