Training jenkinsfile
Some checks failed
s444380-training/pipeline/head There was a failure building this commit

This commit is contained in:
Kamil Guttmann 2022-05-03 14:40:26 +02:00
parent eccbbfdb80
commit 6c8a16fe04
3 changed files with 53 additions and 1 deletions

1
Jenkinsfile vendored
View File

@ -34,6 +34,7 @@ pipeline {
sh "./download_data.sh"
sh "python3 clean_and_split_data.py"
archiveArtifacts artifacts: "crime_test.csv, crime_dev.csv, crime_train.csv", onlyIfSuccessful: true
build job: "s444380-training/master"
}
}
}

44
Jenkinsfile.train Normal file
View File

@ -0,0 +1,44 @@
pipeline {
agent {
docker { image 'kamilguttmann/ium:latest' }
}
parameters {
string (
defaultValue: '100',
description: 'Epochs',
name: 'EPOCHS'
)
buildSelector(
defaultSelector: lastSuccessful(),
description: 'Which build to use for copying artifacts',
name: 'BUILD_SELECTOR'
)
}
stages {
stage('Copy artifacts') {
steps {
copyArtifacts fingerprintArtifacts: true, projectName: 's444380-create-dataset', selector: buildParameter('BUILD_SELECTOR')
}
}
stage("Checkout git") {
steps {
checkout([$class: 'GitSCM', branches: [[name: '*/master']], extensions: [], userRemoteConfigs: [[credentialsId: 's444380', url: 'https://git.wmi.amu.edu.pl/s444380/ium_444380.git']]])
}
}
stage("Train model") {
steps {
sh "./train_model.py $EPOCHS"
archiveArtifacts artifacts: "./model/*", onlyIfSuccessful: true
}
}
}
post {
success {
emailtext body: "SUCCESS", subject: "s444380-training", to: "e19191c5.uam.onmicrosoft.com@emea.teams.ms"
}
failure {
emailtext body: "FAILURE", subject: "s444380-training", to: "e19191c5.uam.onmicrosoft.com@emea.teams.ms"
}
}
}

View File

@ -1,3 +1,5 @@
import sys
import pandas as pd
from sklearn.preprocessing import LabelEncoder
from keras.models import Sequential
@ -63,8 +65,13 @@ model.add(Dense(128, activation='relu'))
model.add(Dense(num_categories, activation='softmax'))
model.compile(optimizer='adam', loss='sparse_categorical_crossentropy', metrics=['accuracy', 'sparse_categorical_accuracy'])
if len(sys.argv) > 1:
epochs = sys.argv[1]
else:
epochs = 10
# Train model
model.fit(x_train, y_train, epochs=100, validation_data=(x_val, y_val))
model.fit(x_train, y_train, epochs=epochs, validation_data=(x_val, y_val))
# Make predictions
y_pred = model.predict(x_test)