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 {
|
||||
dockerfile true
|
||||
}
|
||||
parameters {
|
||||
string(
|
||||
defaultValue: '100',
|
||||
description: 'Example training parameter',
|
||||
name: 'EPOCHS_NUM'
|
||||
)
|
||||
}
|
||||
stages {
|
||||
stage('Stage 1') {
|
||||
steps {
|
||||
sh 'chmod u+x ./simple_regression.py'
|
||||
echo 'Copying datasets from create-dataset...'
|
||||
copyArtifacts filter: '*', projectName: 's449288-create-dataset'
|
||||
echo 'Datasets copied'
|
||||
echo 'Conducting simple regression model test'
|
||||
sh 'python3 simple_regression.py $EPOCHS_NUM'
|
||||
echo 'Model and predictions saved'
|
||||
sh 'head lego_reg_results.csv'
|
||||
sh 'ls -lh lego_reg_model'
|
||||
echo 'Archiving model...'
|
||||
sh 'tar -czf lego_reg_model.tar.gz lego_reg_model/'
|
||||
archiveArtifacts 'lego_reg_model.tar.gz'
|
||||
echo 'Model archived'
|
||||
sh 'chmod u+x ./evaluate.py'
|
||||
echo 'Copying datasets from the create-dataset job...'
|
||||
copyArtifacts filter: 'lego_sets_clean_test.csv', projectName: 's449288-create-dataset'
|
||||
echo 'Datasets copied'
|
||||
echo 'Copying model from the training job...'
|
||||
copyArtifacts filter: 'lego_reg_model.tar.gz', projectName: 's449288-training'
|
||||
echo 'Model copied'
|
||||
sh 'tar xvzf lego_reg_model.tar.gz'
|
||||
echo 'Optional copying of the metrics file from previous build...'
|
||||
copyArtifacts filter: 'eval_results.txt', projectName: 's449288-evaluation', optional: 'True'
|
||||
echo 'Metrics file copied if it didn't exist'
|
||||
echo 'Evaluating model...'
|
||||
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 {
|
||||
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 {
|
||||
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 {
|
||||
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 {
|
||||
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/'
|
||||
archiveArtifacts 'lego_reg_model.tar.gz'
|
||||
echo 'Model archived'
|
||||
echo 'Launching the s449288-evaluation job...'
|
||||
build job: 's449288-evaluation/master/'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user